Skip to main content
3 of 3
Commonmark migration

Two other answers explain what exec "$@" does. This answer on Stack Overflow explains why it’s important for Docker, and as you surmise, it does have to do with signals:

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.

Stephen Kitt
  • 481.5k
  • 60
  • 1.2k
  • 1.4k