Reputation: 11512
I have a base Docker image, Base, that contains a supporting service 'helper' I want to run. This base is not intended for direct use.
If I build another image from Base, is there a way 'helper' can be set to auto-run on start without the author of this new image being aware of having to start it.
For example I know I can doctor the CMD to start 'helper' && then do whatever the author wants. I'm looking for a way to encapsulate starting 'helper' so the image author building on top of Base doesn't have to be aware or do anything.
Possible?
Upvotes: 2
Views: 51
Reputation: 1324537
You can consider using as a base image phusion/baseimage-docker
(which always starts the my_init
script, to take care of the zombie processes)
In that image, you can define multiple program (daemon) to run:
You only have to write a small shell script which runs your daemon, and
runit
will keep it up and running for you, restarting it when it crashes, etc.The shell script must be called
run
, must be executable, and is to be placed in the directory/etc/service/<NAME>
.
If your base image has a /etc/service/helper/run
script, then any image based on it would run helper
, plus any other /etc/service/xxx/run
script of your own.
Upvotes: 1