search

Home  >  Q&A  >  body text

dockerfile - docker中怎样覆盖掉父镜像entrypoint

请教一个问题:
父镜像和子镜像同时指定了entrypoint
子镜像好像不覆盖父镜像的entrypoint
怎样能把父镜像的entrypoint覆盖掉?

PHP中文网PHP中文网2760 days ago1100

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-24 09:15:35

    In fact, the ENTRYPOINT of the child image can override the ENTRYPOINT of the parent image. Let’s take a look at an example:

    Parent image Dockerfile

    FROM ubuntu:14.04
    ENTRYPOINT ["whoami"]

    Build parent image

    sudo docker build -t kiwenlau/father .

    Sub-mirror Dockerfile

    FROM kiwenlau/father
    ENTRYPOINT ["hostname"]

    Build sub-mirror:

    sudo docker build -t kiwenlau/son .

    Run the parent image:

    sudo docker run kiwenlau/father
    root

    Run sub-mirror

    sudo docker run kiwenlau/son
    cb2b314c47db

    It can be seen that the parent image outputs the user name in the container, and the child image outputs the host name of the container. The ENTRYPOINT of the child image overwrites the ENTRYPOINT of the parent image

    reply
    0
  • 怪我咯

    怪我咯2017-04-24 09:15:35

    Based on the last ENTRYPOINT, the previous ones will be overwritten

    reply
    0
  • Cancelreply