Docker-letsencrypt-nginx-proxy-companion: Certificates are saved in every volume

Created on 24 Jan 2017  路  3Comments  路  Source: nginx-proxy/docker-letsencrypt-nginx-proxy-companion

I'm using named volumes with docker-compose v2. When I start the container, the certificates are getting saved in every mounted volume. The same certificates are saved inside certs, conf.d, vhost.d, html and test. Is this the normal behavior? How can I prevent that the certificates are getting saved inside vhost.d?

Docker-compose:

letsencrypt-nginx-proxy-companion:
    build:
      context: .
      dockerfile: Dockerfile.letsencrypt-nginx-proxy-companion
    container_name: letsencrypt-nginx-proxy-companion
    depends_on:
      - nginx-gen
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - nginxstore:/etc/nginx/certs:rw
      - nginxstore:/etc/nginx/conf.d
      - nginxstore:/etc/nginx/vhost.d
      - nginxstore:/usr/share/nginx/html
      - nginxstore:/etc/test
    environment:
      - NGINX_DOCKER_GEN_CONTAINER=nginx-gen
      - ACME_CA_URI=https://acme-staging.api.letsencrypt.org/directory
      - DEBUG=true
    networks:
      - back-tier
More info needed

Most helpful comment

You can correct me, if I am wrong. But you can imagine the volume being a folder from the Docker host machine that is mounted inside the container. So you mount the same folder to multiple folders inside the container.

      - nginxstore:/etc/nginx/certs:rw
      - nginxstore:/etc/nginx/conf.d
      - nginxstore:/etc/nginx/vhost.d
      - nginxstore:/usr/share/nginx/html
      - nginxstore:/etc/test

They all point to the same physical folder, but you expect to see the certificates in some of those mount points, but not on others. How should this work?

All 3 comments

You are using the same volume for all the directories. Use different volumes for each dir or at least for the certs.

Why do I have to use different volumes?
This is my complete docker-compose file.

version: "2"

services:
  nginx:
    build:
      context: .
      dockerfile: Dockerfile.nginx
    container_name: nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - nginxstore:/etc/nginx/certs:ro
      - nginxstore:/etc/nginx/conf.d
      - nginxstore:/etc/nginx/vhost.d
      - nginxstore:/usr/share/nginx/html
    networks:
      - front-tier
      - back-tier

  nginx-gen:
    build:
      context: .
      dockerfile: Dockerfile.docker-gen
    container_name: nginx-gen
    depends_on:
      - nginx
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - nginxstore:/etc/nginx/certs:ro
      - nginxstore:/etc/nginx/conf.d
      - nginxstore:/etc/nginx/vhost.d
      - nginxstore:/usr/share/nginx/html
    entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
    networks:
      - back-tier

  letsencrypt-nginx-proxy-companion:
    build:
      context: .
      dockerfile: Dockerfile.letsencrypt-nginx-proxy-companion
    container_name: letsencrypt-nginx-proxy-companion
    depends_on:
      - nginx-gen
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - nginxstore:/etc/nginx/certs:rw
      - nginxstore:/etc/nginx/conf.d
      - nginxstore:/etc/nginx/vhost.d
      - nginxstore:/usr/share/nginx/html
    environment:
      - NGINX_DOCKER_GEN_CONTAINER=nginx-gen
      #- ACME_CA_URI=https://acme-staging.api.letsencrypt.org/directory
      #- DEBUG=true
    networks:
      - back-tier

volumes:
  #######################################
  # Storage nginxstore
  #######################################
  nginxstore:
    driver: local

networks:
  front-tier:
    driver: bridge
  back-tier:

You can correct me, if I am wrong. But you can imagine the volume being a folder from the Docker host machine that is mounted inside the container. So you mount the same folder to multiple folders inside the container.

      - nginxstore:/etc/nginx/certs:rw
      - nginxstore:/etc/nginx/conf.d
      - nginxstore:/etc/nginx/vhost.d
      - nginxstore:/usr/share/nginx/html
      - nginxstore:/etc/test

They all point to the same physical folder, but you expect to see the certificates in some of those mount points, but not on others. How should this work?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrg20 picture mrg20  路  5Comments

MarcSN311 picture MarcSN311  路  5Comments

nosovk picture nosovk  路  5Comments

KetchupBomb picture KetchupBomb  路  6Comments

codeHorse87 picture codeHorse87  路  4Comments