Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to entrypoint of Docker parent image when child defines another one?

Let's say I've got the Docker image parent built by this Dockerfile:

FROM ubuntu ENTRYPOINT ["parent-entry"] 

Now I inherit from this parent image in my child image built with this code:

FROM parent ENTRYPOINT ["child-entry"] 

As far as I have tested it the entrypoint of the child image overwrites the one in the parent image.

But since I am new to Docker I am not sure about this. My research also hasn't yet resulted in a satisfying answer. So is the assumption above correct?

like image 304
Harold L. Brown Avatar asked Nov 14 '16 15:11

Harold L. Brown


People also ask

Can a Dockerfile have two ENTRYPOINT?

According to the documentation however, there must be only one ENTRYPOINT in a Dockerfile.

Does Docker run override ENTRYPOINT?

ENTRYPOINT is the other instruction used to configure how the container will run. Just like with CMD, you need to specify a command and parameters. However, in the case of ENTRYPOINT we cannot override the ENTRYPOINT instruction by adding command-line parameters to the `docker run` command.

Does a Docker image need an ENTRYPOINT?

Any Docker image must have an ENTRYPOINT or CMD declaration for a container to start. Though the ENTRYPOINT and CMD instructions may seem similar at first glance, there are fundamental differences in how they build container images. (This is part of our Docker Guide.

Can I use both ENTRYPOINT and CMD?

Example of using CMD and ENTRYPOINT togetherIf both ENTRYPOINT and CMD are present, what is written in CMD is executed as an option of the command written in ENTRYPOINT. If an argument is added at the time of docker run , the contents of CMD will be overwritten and the ENTRYPOINT command will be executed.


1 Answers

The last entrypoint is used, only the last one.

You can check, put several lines with different ENTRYPOINT in your Dockerfile, and check what happens.

like image 89
user2915097 Avatar answered Oct 23 '22 02:10

user2915097