Skip to content

Instantly share code, notes, and snippets.

@entone
Last active February 8, 2020 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save entone/472bf7aaca4add11fa7defdb3f8aae7d to your computer and use it in GitHub Desktop.
Save entone/472bf7aaca4add11fa7defdb3f8aae7d to your computer and use it in GitHub Desktop.
Dockerfile multiple start commands with ctrl-c and graceful stop

Initially I had the nginx command in the start script, but BASH was ignoring SIGINT signals, or capturing them but not forwarding them to the Nginx daemon.

This snippet allows docker stop <hash> to shutdown the container properly, without waiting the default 10 seconds for cleanup, and ctrl-c works as expected.

Dockerfile

CMD /app/start.sh && \
  exec nginx -g 'daemon off;'

CLI

$ docker run -it <hash>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment