61

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?

Harold L. Brown
  • 8,423
  • 11
  • 57
  • 109
  • 6
    The docs for [`ENTRYPOINT`](https://docs.docker.com/engine/reference/builder/) state: *Only the last ENTRYPOINT instruction in the Dockerfile will have an effect.* – Roman Nov 14 '16 at 16:24
  • 4
    But in this example there are TWO Dockerfiles, each with its own single ENTRYPOINT. The child Dockerfile inherits from a parent image. So the child must know the parent Dockerfile's ENTRYPOINT and either not override it, or else repeat it and add to it, correct? – Chris Robinson Jun 05 '18 at 14:08

1 Answers1

47

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.

v.ladynev
  • 19,275
  • 8
  • 46
  • 67
user2915097
  • 30,758
  • 6
  • 57
  • 59
  • 11
    How can you add scripts to run after the parent ENTRYPOINT has executed? – Stephane Apr 09 '20 at 16:17
  • 1
    @Stephane you don't. That's typically when you start to need an init system in your container, such as s6-overlay, tini, dumb-init, etc. – NewbiZ May 29 '23 at 00:31