Philip Kirkbride
Philip Kirkbride

Reputation: 22899

Keep docker-compose container running after ENTRYPOINT

Originally the final line of my Dockerfile read:

RUN puppet apply /etc/puppetlabs/puppet/master.pp

I need the command to run only once the container is created and mounted, so I changed to:

ENTRYPOINT puppet apply /etc/puppetlabs/puppet/master.pp

The change fixes my original issue but creates another, the container stops after the command finishes.

I found I can keep the container running by by adding something like && while true; do sleep 1000; done.

This seems a little hacky and I'm wondering if there is a better way to keep my container from stopping?

Note: I've seen some suggestions online where people use flags when running the docker command. So I will point out that I'm initializing this container using docker-compose.

Upvotes: 1

Views: 999

Answers (1)

CFrei
CFrei

Reputation: 3627

I use && sleep infinity. (Be aware that busybox sleep does not provide infinity - only the coreutils do.)

Upvotes: 1

Related Questions