restart nginx container when upstream servers is updated

前端 未结 4 878
情歌与酒
情歌与酒 2020-12-24 13:48

I want to add/remove servers in my nginx running inside a docker container

I use ADD command in Dockerfile to add my nginx.conf to /etc/nginx dir.

#          


        
相关标签:
4条回答
  • 2020-12-24 14:27

    to reload the NGINX configuration run the command

    docker kill -s HUP container_name

    https://blog.docker.com/2015/04/tips-for-deploying-nginx-official-image-with-docker/

    0 讨论(0)
  • 2020-12-24 14:29

    restarting the container is not advisable when you initialize Docker Swarm because it may remove the nginx service. So if you need an alternative aside docker restart; You can go inside the container and just run nginx -s reload

    For example, in docker env, if you have the container named nginx

    docker exec <nginx_container_id> nginx -s reload
    
    0 讨论(0)
  • 2020-12-24 14:45

    If you want to restart the NGINX process, restart the container by running the command:

    docker restart <container name>
    

    https://blog.docker.com/2015/04/tips-for-deploying-nginx-official-image-with-docker/

    0 讨论(0)
  • 2020-12-24 14:51

    If you want to do this from within a container, you will need service/configuration discovery. Tools like coreOS/etcd and Apache Zookeeper are made to facilitate this process. Fair warning: for simple applications, these can be a bit difficult to manage.

    There is also docker-gen, which is somewhat easier to get going. There is even a specific pre-made script for exactly the scenario you are describing.

    0 讨论(0)
提交回复
热议问题