Hi, I am having a problem with the nginx-letsencrypt container and I can't find a solution...
I have this docker-compose:
```version: "2"
services:
nginx-proxy:
restart: always
image: jwilder/nginx-proxy:alpine
container_name: nginx-proxy
privileged: true
ports:
- "80:80"
- "443:443"
volumes:
- "/etc/nginx/vhost.d"
- "/usr/share/nginx/html"
- "/etc/nginx-proxy/certs:/etc/nginx/certs:ro"
- "/var/run/docker.sock:/tmp/docker.sock:ro"
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
nginx-letsencrypt:
restart: always
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginx-letsencrypt
depends_on:
- nginx-proxy
volumes_from:
- nginx-proxy
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "/etc/nginx-proxy/certs:/etc/nginx/certs:rw"
environment:
- NGINX_PROXY_CONTAINER=nginx-proxy
sttdb-client:
image: sttdb/sttdb-client
container_name: sttdb-client
environment:
- VIRTUAL_HOST=sttdb.udl.cat
- LETSENCRYPT_HOST=sttdb.udl.cat
- LETSENCRYPT_EMAIL=ma*
```
And I am getting the error:
nginx-letsencrypt | Error: can't get docker-gen container id !
nginx-letsencrypt | If you are running a three containers setup, check that you are doing one of the following :
nginx-letsencrypt | - Set the NGINX_DOCKER_GEN_CONTAINER env var on the letsencrypt-companion container to the name of the docker-gen container.
nginx-letsencrypt | - Label the docker-gen container to use with 'com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen.'
I try to use the jrcs/letsencrypt-nginx-proxy-companion:v1.7 and I get the error:
nginx-letsencrypt | Error: can't write to the '/etc/nginx/certs' directory !
nginx-letsencrypt | Check that '/etc/nginx/certs' directory is export as a writable volume.
nginx-letsencrypt | Warning: '/etc/nginx/certs' does not appear to be a mounted volume.
I know it has rw in the letsencrypt volume, but I also changed the ro permission to rw in the nginx container and I have the same error.
Hi, could you try with jwilder/nginx-proxy instead of jwilder/nginx-proxy:alpine ?
Scratch the previous suggestion, I just tried your compose file and everything started ok, including getting a test certificate.
What version of Docker and Docker Compose are you using, and what OS is your Docker host running on ? I just tried with Docker 18.05.0-ce and Docker Compose 1.21.2 on Ubuntu 18.04.
Any particular reason to run you nginx-proxy container with privileged: true ? If not, you probably shouldn't.
Could you try using a named volume instead of a host volume for /etc/nginx/certs ? In my opinion using host volumes with Docker often ends up in permission issues.
By the way you don't need to use volumes_from AND the NGINX_PROXY_CONTAINER env var AND the com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy for the le-companion to find the proxy container ID. Only one of them is enough. As you already use volumes_from I'd suggest you remove the env var and the label
example compose file with the suggested modifications (tested and working under the same environment) :
version: '2'
services:
nginx-proxy:
restart: always
image: jwilder/nginx-proxy:alpine
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- "/etc/nginx/vhost.d"
- "/usr/share/nginx/html"
- "certs:/etc/nginx/certs:ro"
- "/var/run/docker.sock:/tmp/docker.sock:ro"
nginx-letsencrypt:
restart: always
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginx-letsencrypt
depends_on:
- nginx-proxy
volumes_from:
- nginx-proxy
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "certs:/etc/nginx/certs:rw"
sttdb-client:
image: sttdb/sttdb-client
container_name: sttdb-client
environment:
- VIRTUAL_HOST=your.domain.tld
- LETSENCRYPT_HOST=your.domain.tld
- [email protected]
volumes:
certs:
Hi! First of all, thank you for the help.
Now using the compose config you posted, I get the error:
nginx-letsencrypt | Error: can't write to the '/etc/nginx/certs' directory !
nginx-letsencrypt | Check that '/etc/nginx/certs' directory is export as a writable volume.
I am using CentOS 7, docker 1.13.1 and docker-compose 1.21.2.
EDIT: Okay, upgrade on docker, now having docker-ce 18.05.0. It seems to work, thank you!
Docker 1.13.1 isn't that old, I'd be curious to know why it did not work.
Error: nginx-proxy container 78100e16e0fd7cbc9f11e3b9ddfdf0e87b070ca8aad9e00985278d71a06698af isn't running.
help please
Most helpful comment
Scratch the previous suggestion, I just tried your compose file and everything started ok, including getting a test certificate.
What version of Docker and Docker Compose are you using, and what OS is your Docker host running on ? I just tried with Docker 18.05.0-ce and Docker Compose 1.21.2 on Ubuntu 18.04.
Any particular reason to run you nginx-proxy container with
privileged: true? If not, you probably shouldn't.Could you try using a named volume instead of a host volume for
/etc/nginx/certs? In my opinion using host volumes with Docker often ends up in permission issues.By the way you don't need to use
volumes_fromAND theNGINX_PROXY_CONTAINERenv var AND thecom.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxyfor the le-companion to find the proxy container ID. Only one of them is enough. As you already usevolumes_fromI'd suggest you remove the env var and the labelexample compose file with the suggested modifications (tested and working under the same environment) :