CMD /my-cleaner.sh & \
&& /init
[...]
Does the above look right?
Nope, that's not how CMD works. It needs to be given a single command.
I don't know the specifics of /init, because I'm using tini instead.
But the purpose is probably the same: Have a minimal init process run
as pid 1 (process ID 1), so that signal propagation to child processes
is handled correctly. Default signal handling is different for pid 1
than for all other processes.[1]
The setup I use is:
- set ENTRYPOINT to tini, or some other minimal init system
- use CMD for what I actually want to run, usually a bash script
For example:
ENTRYPOINT ["/sbin/tini", "-g", "--"]
CMD ["/path/to/my/bash/script.sh"]
The bash script starts with this line:
#!/usr/bin/env bash
Alternatively, you could try
CMD ["/bin/bash", "/path/to/my/bash/script.sh"]
If I am mistaken and /init is not a minimal init process to be used
as entry point, but some regular command to be executed, try this:
CMD ["/bin/bash", "-c", "/my-cleaner.sh & exec /init"]
That is a single command, namely bash, which then interprets the
arguments as a command line and starts child processes as required.
Hope that helps,
Roland
[1]
https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-pr...