Docker ENTRYPOINT和Kubernetes容器规范COMMAND之间的区别? [英] Difference between Docker ENTRYPOINT and Kubernetes container spec COMMAND?

查看:329
本文介绍了Docker ENTRYPOINT和Kubernetes容器规范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文件中覆盖默认的Entrypoint和Cmd时,将应用以下规则:

When you override the default Entrypoint and Cmd in Kubernetes .yaml file, these rules apply:

  • 如果不为容器提供命令或参数,则默认为 使用Docker映像中定义的内容.
  • 如果仅为容器提供args,则默认入口点 Docker映像中定义的定义是使用您提供的args运行的.
  • 如果您提供容器的命令,则仅 使用提供的命令.默认的EntryPoint和默认的Cmd 在Docker映像中定义的将被忽略.您的命令是 使用提供的args运行(如果未提供,则不提供args.)
  • If you do not supply command or args for a Container, the defaults defined in the Docker image are used.
  • If you supply only args for a Container, the default Entrypoint defined in the Docker image is run with the args that you supplied.
  • If you supply a command for a Container, only the supplied command is used. The default EntryPoint and the default Cmd defined in the Docker image are ignored. Your command is run with the args supplied (or no args if none supplied).

这里是一个示例:

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容器规范COMMAND之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆