I have docker nginx running in docker swarm. I want to change settings of nginx without container restart. I replaced nginx conf file inside container but I cannot reload configuration
Tried
root@xxx:/# service nginx
Usage: /etc/init.d/nginx {start|stop|status|restart|reload|force-reload|upgrade|configtest}
root@xxx:/# service nginx reload
[....] Reloading nginx: nginxstart-stop-daemon: warning: failed to kill 1: Permission denied
failed!
root@xxx:/# service nginx force-reload
[....] Reloading nginx: nginxstart-stop-daemon: warning: failed to kill 1: Permission denied
failed!
root@xxx:/# nginx -s reload
2017/03/17 12:57:05 [notice] 281#281: signal process started
2017/03/17 12:57:05 [alert] 281#281: kill(1, 1) failed (13: Permission denied)
nginx: [alert] kill(1, 1) failed (13: Permission denied)
root@xxx:/# ps aux | grep nginx
root 1 0.0 0.1 36124 5500 ? Ss Mar09 0:00 nginx: master process nginx -g daemon off;
nginx 9 0.0 0.1 37328 4476 ? S Mar09 7:32 nginx: worker process
root 243 0.0 0.0 11128 1020 ? S+ 12:45 0:00 grep nginx
root@xxx:/# kill -HUP 1
bash: kill: (1) - Permission denied
It is possible to do?
You seem to be on the wrong track: The point of running services inside a docker swarm is that any instance can go away at any time (e.g. at node failure) and be replaced by a freshly created new one.
This means that you should not manipulate containers that belong to a service managed by a swarm cluster because your changes can get lost at any time.
You seem to have docker exec
'd into such a container and manually edited the config file. This is a no-go. Your change is very volatile.
A better solution would be to create an image with your custom configuration for use in swarm. Any time your config changes, update the image and replace the running instance(s) with docker service update --image my-custom-image:new-version <my-service>
. Docker will take care of rolling out the update. If your service is running with multiple instances, the update will cause no downtime (rolling update).
That said, what you really asked for should work if you send the kill signal to the container from outside, e.g. docker kill -s HUP container-name
issued on the Docker node where the service instance is actually running. As you already modified the config inside the container, you obviously know how to find the container.