skip to Main Content

I have a docker container that runs nginx on debian. In response to some input, I need to restart the nginx service but not the whole container. Running "service nginx restart" blows the whole container away.

Is there any way to restart a service in a docker container without restarting the whole container?

2

Answers


  1. You can go inside the container and restart the nginx

    sudo docker exec –it nginx-container /bin/bash
    
    Login or Signup to reply.
  2. Of course it’s recommended to rebuild the container when you do the changes, but I recommend reloading the nginx service with either running bash inside of container and then reload it:

    sudo docker exec -it NGINX_NAME bash
    

    Then run service nginx reload.

    Or:

    sudo docker exec -it NGINX_NAME service nginx reload
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search