父 docker 中的 CMD 是否被子 docker 映像中的 CMD/ENTRYPOINT 覆盖? [英] Is CMD in parent docker overriden by CMD/ENTRYPOINT in child docker image?

查看:59
本文介绍了父 docker 中的 CMD 是否被子 docker 映像中的 CMD/ENTRYPOINT 覆盖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图弄脏 docker.我知道 CMDENTRYPOINT 用于指定 docker 映像的启动/可运行命令,并且 CMDENTRYPOINT.但我不知道,当父 docker 映像也有 CMD OR ENTRYPOINT 或 BOTH 时,它是如何工作的?

I am trying to get my hands dirty on docker. I know that CMD or ENTRYPOINT is used to specify the start/runnable command for docker image and CMD is overridden by ENTRYPOINT. But I don't know, how does it works, when parent docker image, also has CMD OR ENTRYPOINT or BOTH ?

子图像是否从父 docker 图像继承这些值?如果是这样,那么父图像中的 ENTRYPOINT 会覆盖子图像中的 CMD 吗?

Does child image inherit those values from parent docker image ? If so, then does ENTRYPOINT in parent image override CMD in child image ?

我知道这样的问题已经在 https://github.com/docker/compose/问题/3140.但是,讨论已经很老了(2-3 年前),并没有清楚地回答我的问题.

I know that such question is already discussed at https://github.com/docker/compose/issues/3140. But, the discussion is quite old(before 2-3 years) and it doesn't answer my question clearly.

提前致谢.

推荐答案

如果你在子图像中定义了一个 ENTRYPOINT,它会将 CMD 的值清空为在这个问题中确定.目的是避免出现令人困惑的情况,即入口点作为 args 传递给您不再想运行的命令.

If you define an ENTRYPOINT in a child image, it will null out the value of CMD as identified in this issue. The goal is to avoid a confusing situation where an entrypoint is passed as args a command you no longer want to run.

除此特定情况外,ENTRYPOINTCMD 的值是继承的,并且可以被子图像甚至同一 Dockerfile 的后续步骤单独覆盖.图像中只有一个值,最后一个定义的值具有优先权.

Other than this specific situation, the value of ENTRYPOINT and CMD are inherited and can be individually overridden by a child image or even a later step of the same Dockerfile. Only one value for each of these will ever exist in an image with the last defined value having precedence.

这篇关于父 docker 中的 CMD 是否被子 docker 映像中的 CMD/ENTRYPOINT 覆盖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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