docker-gen: Restart unless stopped not working
I noticed restart: unless-stopped
is not working in docker-gen. Do I need to use always
instead? Why is it not working?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 12
- Comments: 22 (2 by maintainers)
Commits related to this issue
- Fix exit(2) on SIGHUP before fully initialized. Fixes https://github.com/jwilder/docker-gen/issues/244 — committed to JoelLinn/docker-gen by JoelLinn 4 years ago
- Fix exit(2) on SIGHUP before fully initialized. Fixes https://github.com/jwilder/docker-gen/issues/244 — committed to bugficks/docker-gen by JoelLinn 4 years ago
- Fix exit(2) on SIGHUP before fully initialized. Fixes https://github.com/jwilder/docker-gen/issues/244 — committed to JoelLinn/docker-gen by JoelLinn 4 years ago
Cause
SIGHUP
is used to trigger generation. If the signal however is received beforedocker-gen
is fully initialized the default golang handler will callos.Exit(2)
. I fixed this by ignoringSIGHUP
untildocker-gen
is ready.Fix
You can use the docker image based on my fork: joellinn/docker-gen. It’s also build with up to date dependencies.
(I don’t fancy advertising forks but this project unfortunately seems to be unmaintained…)
I’m hitting the same issue - docker-gen container + nginx container - both restart=always - if I restart the docker service, nginx comes back up but docker-gen remains stopped with an exit code of 2
Nothing obvious in the logs
Docker start will get the container running again
I have the same problem. But also “always” does not work. After restart of the server I have to startup docker-gen manually. How can I find the reason for the exited docker-image? Why does it not restart automatically when I use always?
Yep, exactly the same for me. Possible to fix this issue? It is very annoying in a production environment.
Same here. Ubuntu 18.04.
We’re having the same issue: nginx-gen randomly goes into the “stopped” state, even though we have a restart directive…
We worked around this problem by wrapping docker-gen in a shell script that executes docker-gen in a loop and traps SIGHUP and SIGTERM signals: