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
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
Build parent image
Sub-mirror Dockerfile
Build sub-mirror:
Run the parent image:
Run sub-mirror
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