dockerfile - docker中怎样覆盖掉父镜像entrypoint
PHP中文网
PHP中文网 2017-04-24 09:13:35
0
2
1027

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

PHP中文网
PHP中文网

认证0级讲师

reply all (2)
Ty80

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

    刘奇

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

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!