Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker CMD when base image has a CMD?

Tags:

docker

I have a Dockerfile which starts with:

FROM puppet/puppetserver

When I look at the source container it is built from another:

FROM puppet/puppetserver-standalone:5.0.0

The second contains a CMD command:

ENTRYPOINT ["dumb-init", "/docker-entrypoint.sh"]
CMD ["foreground" ]

In my own container I end with:

COPY start.sh /
CMD /start.sh

The CMD run but with unexpected results:

puppetserver: '/bin/sh' is not a puppetserver command. See 'puppetserver --help'.

I know that I have bash availible because I'm using RUN commands.sh before CMD in the same Dockerfile.

How do CMD commands stack when inheriting from base images?

Is my CMD not run as a normal bash command and instead run in conjunction with the CMD of the base image?

like image 552
Philip Kirkbride Avatar asked Oct 25 '25 13:10

Philip Kirkbride


1 Answers

You need to reset the ENTRYPOINT from the parent image

COPY start.sh /
ENTRYPOINT []
CMD /start.sh
like image 62
Tarun Lalwani Avatar answered Oct 28 '25 04:10

Tarun Lalwani