1、docker 搜索nginx、拉取nginx镜像、制作tag
// 搜索镜像
docker search nginx
// 拉取镜像
docker pull nginx
// 用nginx(4f380adfc10f)镜像制作tag
docker docker tag 4f380adfc10f test/nginx:v1
2、编写yml
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
name: web
spec:
containers:
- name: nginx
image: test/nginx:v1 # 上面制作的tag
ports:
- containerPort: 80
3、日常操作
// 创建pod
kubectl create -f xxx.yml
// 查询pod
kubectl get pods
kubectl get pods -o wide
kubectl describe pods
// 删除镜像,如nginx(上面的metadata.name)
kubectl delete pod nginx
4、启动成功
MacBook-Air:test chenfenli$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 18h 10.1.0.239 docker-desktop <none> <none>
MacBook-Air:test chenfenli$