docker-gen: docker-gen exits with status code 2
I’ve been pulling my hair out all night. As far as i can tell - running docker-gen as a container - the container should continue running. However, i have an intermitient situation where the container exits with status code 2.
when this happens, my config files are not being created…
this is the docker-compose file (with some omissions for privacy) - does it look right? It’s essentially copied out of the examples with paths updates her and there.
version: '2'
services:
node:
# node image
build: "docker-node"
container_name: node
volumes:
- ./volumes/www:/data/app
ports:
- "3000:3000"
environment:
NODE_ENV: "development"
working_dir: /data/app
command: ["npm install; npm run develop"]
nginx:
image: nginx
container_name: nginx
ports:
- "80:80"
- "443:443"
volumes:
- "/etc/nginx/conf.d"
- "/etc/nginx/vhost.d"
- "/usr/share/nginx/html"
- "./volumes/proxy/certs:/etc/nginx/certs:ro"
networks:
- proxy-tier
nginx-gen:
image: jwilder/docker-gen
container_name: nginx-gen
depends_on:
- letsencrypt-nginx-proxy-companion
- simple-site
- nginx
volumes:
- "/var/run/docker.sock:/tmp/docker.sock:ro"
- "./volumes/proxy/templates/nginx-compose-v2.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro"
volumes_from:
- nginx
entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -only-exposed -wait 30s:60s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
letsencrypt-nginx-proxy-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt-nginx-proxy-companion
volumes_from:
- nginx
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./volumes/proxy/certs:/etc/nginx/certs:rw"
environment:
- NGINX_DOCKER_GEN_CONTAINER=nginx-gen
simple-site:
image: nginx
container_name: simple-site
depends_on:
- letsencrypt-nginx-proxy-companion
volumes:
- "./volumes/nginx.conf/www/conf.d/:/etc/nginx/conf.d"
- "./volumes/www/public:/usr/share/nginx/html"
environment:
- VIRTUAL_HOST=xxxxx
- VIRTUAL_NETWORK=nginx-proxy
- VIRTUAL_PORT=80
- LETSENCRYPT_HOST=xxxxx
- LETSENCRYPT_EMAIL=xxxxx
networks:
- proxy-tier
networks:
proxy-tier:
external:
name: nginx-proxy
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 3
- Comments: 19
Commits related to this issue
- Try fix for docker-gen container https://github.com/jwilder/docker-gen/issues/201 — committed to Fongshway/docker-nginx-letsencrypt-sample by deleted user 7 years ago
- Weird changes As with all things modern, I had to do some weird stuff. For instance, I needed to change the command and entrypoint because docker-gen was crashing. https://github.com/jwilder/docker-g... — committed to ereadingtool/ereadingtool by jdelamare 4 years ago
I resolved my issue by changing the entrypoint to the default “/bin/sh -c” and moving the entrypoint command “docker-gen xxx” to the ‘command’
The relevant docker-compose.yml snippet looks like:
@arcticShadow s solution worked for me. But first I had to delete the container with
Unfortunately the @thomaco appears 😦 Is there any workaround?
I was able to reliably reproduce this - I was using the recommended setup for ngnix+letsecrypt+docker-gen containers - any attempt to restart docker resulted in the docker-gen container being stopped with an exit status of 2 - despite ‘restart=always’
The recommended setup sets the container to always be the same -
nginx-gen
- I found removing the fixed name and using a label on the docker-gen container to identify the container instead seems to have solved the restart issue but I’ve no idea why ?@arcticShadow I’ve been having this same issue as well – the docker-gen container seems to run fine for days until it’s terminated randomly for some reason. I’ve used your fix regarding the change in entrypoint and CMD and so far, so good.
Could you explain why changing the entrypoint to
/bin/sh
(and thus running everything through shell) solves this issue? Isn’t this some kind of deeper underlying issue we should deal with instead?