You could use this CMD in your Dockerfile
:
CMD exec /bin/bash -c "trap : TERM INT; sleep infinity & wait"
This will keep your container alive until it is told to stop. Using trap and wait will make your container react immediately to a stop request. Without trap/wait stopping will take a few seconds.
For busybox based images (used in alpine based images) sleep does not know about the infinity argument. This workaround gives you the same immediate response to a docker stop
like in the above example:
CMD exec /bin/sh -c "trap : TERM INT; sleep 9999999999d & wait"