As @Peter Lyons says, using exec
will replace the parent process, rather than have two processes running.
This is important in Docker for signals to be proxied correctly. For example, if Redis was started without exec
, it will not receive a SIGTERM
upon docker stop
and will not get a chance to shutdown cleanly. In some cases, this can lead to data loss or zombie processes.
If you do start child processes (i.e. don’t use exec
), the parent process becomes responsible for handling and forwarding signals as appropriate. This is one of the reasons it’s best to use supervisord
or similar when running multiple processes in a container, as it will forward signals appropriately.