NGINX: Restart inside a container

If we need to edit/check nginx configuration inside a Docker container, esecially if we use FROM nginx:stable-alpine image, we can do the following:

  • e.g. use a Portainer to connect to working container (or via docker container exec)
  • edit nginx.conf: vi /etc/nginx/nginx.conf
  • add or edit anything
  • check your new config is correct: nginx -t
  • reload service inside a container: nginx -s reload