開始使用Kubernetes和docker
docker命令
-
運行一個容器
docker run busybox echo "Hello world" -
構建容器鏡像
docker build -t imageName . # docker bulid -t <imageName> <Dockerfile位置,一般就用 .> # 鏡像名只能小寫 -
列出本地鏡像
docker images -
指定埠、后臺運行容器
dokcer run --name myContainer -p 8080:8080 -d buxybox # --name 指定容器名字 # -p 指定埠映射 # -d 指定后臺運行 -
查看容器
# 查看運行中的容器 dokcer ps # 查看所有容器 docker ps -a -
在容器內部運行shell
docker exec -it <containerName> bash # exec在容器內執行命令 # -i 確保輸入流始終開放 # -t 分配一個偽終端 -
停止和洗掉容器
# 停止容器 docker stop <containerName> # 洗掉容器 docker rm <containerName> -
給鏡像打上標簽
docker tag <containerName> <new_containrtName> -
上推和下拉鏡像
docker pull docker push
kubectl命令
-
查看資源資訊
kubectl get <resourceName> # k8s中大部分資源都可以通過get命令查看 -
查看資源實體的資訊
kubectl describe <resourceName> <instanceName> # 例如 kubectl describe pod busybox -
kubectl運行一個Pod
kubectl run <podName> --image=<imageName> # 關于資源的命名,只能由小寫字母或者‘-’和‘.’來組成 -
修改期望的副本數
kubectl scale <resourceName> <instanceName> --replicas=<num> # 將實體的期望副本數設定為num -
查看Pod的ip和所在的node
kubectl get pods -o wide -
在pod中執行shell
kubectl exec -it <podName> bash
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/262835.html
標籤:其他
上一篇:談一下稀疏陣列
