CMD与ENTRYPOINT的区别

CMD ["/script.sh"] docker run的启动参数则会覆盖这个命令

ENTRYPOINT ["/script.sh"] docker run启动参数作为它的参数

k8s对应CMD的配置例子参考如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
apiVersion: v1
kind: Pod
metadata:
  name: print-pod
spec:
  containers:
  - name: print-container
    image: my-image:latest
    command: ["/usr/local/bin/python"]
    args: ["/print.py", "hello k8s"]

相当于覆盖原有CMD命令

nginx的CMD:

1
CMD ["nginx" "-g" "daemon off;"]

nginx-1.22.1的docker镜像的镜像层次结构:

https://hub.docker.com/layers/library/nginx/1.22.1/images/sha256-9081064712674ffcff7b7bdf874c75bcb8e5fb933b65527026090dacda36ea8b?context=explore