Docker ENTRYPOINT 和 Kubernetes 容器规范命令之间的区别? [英] Difference between Docker ENTRYPOINT and Kubernetes container spec COMMAND?
问题描述
Dockerfile 有一个 ENTRYPOINT 参数,在编写 Kubernetes 部署 YAML 文件时,容器规范中有一个 COMMAND 参数.
Dockerfile has a parameter for ENTRYPOINT and while writing Kubernetes deployment YAML file, there is a parameter in Container spec for COMMAND.
我不知道有什么区别以及如何使用它们?
I am not able to figure out what's the difference and how each is used?
推荐答案
Kubernetes 为我们提供了多种使用这些命令的选项:
Kubernetes provides us with multiple options on how to use these commands:
当您覆盖 Kubernetes .yaml 文件中的默认入口点和 Cmd 时,这些规则适用:
When you override the default Entrypoint and Cmd in Kubernetes .yaml file, these rules apply:
- 如果您不为容器提供命令或参数,则使用默认值使用 Docker 镜像中定义的内容.
- 如果您只为容器提供参数,则默认入口点Docker 映像中定义的参数使用您提供的参数运行.
- 如果您为容器提供命令,则只有使用提供的命令.默认入口点和默认 CmdDocker 映像中定义的内容将被忽略.你的命令是使用提供的 args 运行(如果没有提供,则不提供 args).
这是一个例子:
Dockerfile:
Dockerfile:
FROM alpine:latest
COPY "executable_file" /
ENTRYPOINT [ "./executable_file" ]
Kubernetes yaml 文件:
Kubernetes yaml file:
spec:
containers:
- name: container_name
image: image_name
args: ["arg1", "arg2", "arg3"]
https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/
这篇关于Docker ENTRYPOINT 和 Kubernetes 容器规范命令之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!