Docker: Reload Nginx Inside Container

If you want to update Nginx configuration or renew SSL certificates, you should reload Nginx to apply modifications.

If you run Nginx inside Docker container you might be curious how to reload it without any downtime or connection interruptions.

The best way to reload Nginx inside Docker container is to run docker container exec command and send reload signal to the Nginx.

Cool Tip: Enter a running Docker container and start a bash session! Read More →

Check Nginx configuration for correct syntax:

$ docker container exec <container> nginx -t

Reload Nginx inside Docker container:

$ docker container exec <container> nginx -s reload
Recommended Book
git

Docker is rapidly changing the way organizations deploy software at scale.

With the updated edition of this practical guide, you’ll learn how to use Docker to package your applications with all of their dependencies and then test, ship, scale, and support your containers in production.

3 Replies to “Docker: Reload Nginx Inside Container”

  1. I found https://blog.docker.com/2015/04/tips-for-deploying-nginx-official-image-with-docker/, where they say:

    docker kill -s HUP

    Wouldn’t this work as well?

    1. Using kill is bad practice you could avoid using that.

  2. it is not a bad practice, because reload IS a HUP signal anyway….

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.