Docker&AKS相关命令

制作docker镜像

docker build -t <your-name-for-the-image> –file <path-to-your-Dockerfile>  <path-to-project>

例:docker build -t video-streaming –file Dockerfile .

显示docker镜像

docker image list

docker镜像加载到容器

docker run -d -p 3000:3000 video-streaming

停止运行并删除容器

docker kill <your-container-id>

docker rm <your-container-id>

彻底删除镜像

docker rmi <your-image-id> –force

利用compose批量挂载多个docker文件

docker-compose up –build

利用compose批量卸载多个docker文件

docker-compose down

docker-compose down && docker-compose up –build

Docker镜像使用(阿里)

  “registry-mirrors”: [

    “https://j36f7zw9.mirror.aliyuncs.com

  ],

Docker镜像进入

$ sudo docker ps  

$ sudo docker exec -it 775c7c9ee1e1 /bin/bash  

Docker日志

docker logs [OPTIONS] CONTAINER

Azure的ACR的命令

建立镜像库

$registry = New-AzContainerRegistry -ResourceGroupName “myResourceGroup” -Name “myContainerRegistry007” -EnableAdminUser -Sku Basic

登陆远端镜像库

docker login flixtubeinfony.azurecr.io –username InfonyReg –password Qm/umaR8cjhdg93Bc/ZXTxmHeixMCDdV

打标签,并push到远端镜像库

docker tag flixtubeinfony.azurecr.io/video-streaming:latest

docker push flixtubeinfony.azurecr.io/video-streaming:latest

Azure Storage

    environment:

      – PORT=80

      – STORAGE_ACCOUNT_NAME=infony

      – STORAGE_ACCESS_KEY=YoYVUiph3v0Lmp9aNk+1F68kuHLddixJTdM4ZGtyBhzhb0yMpZiCruPnMtQvARhnzA8d2ocWOLOTWEHhqS37MQ==

Terraform相关命令

Terraform初期化/计划/执行/销毁

terraform init

terraform plan

terraform apply -auto-approve

terraform destroy

K8S相关命令

设定AKS的config文件

az aks get-versions –location westus –output table

az aks get-credentials –resource-group flixtube –name flixtube

执行完后,建立~/.kube/config

获取token示例

az ad sp create-for-rbac –role=”Contributor” –scopes=”/subscriptions/a495fe79-8307-4153-b6c3-f40b487cc8f8″

  “appId”: “751258fd-a1a4-43f7-87a9-8b5060f227ad”,

  “displayName”: “azure-cli-2021-08-02-06-22-04”,

  “name”: “751258fd-a1a4-43f7-87a9-8b5060f227ad”,

  “password”: “SuE_Hg150LsDt_KCp3cruu-1cGCo8mRC_E”,

  “tenant”: “be8bec0d-1095-4b1d-b59f-e7412eb0b2f6”

安装K8S Dashboard

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml

Kubectl获取服务list,POD,LOG

kubectl get services

kubectl get pods 

kubectl logs video-streaming-d578d6fd8-ncpx8 -p