Why is docker-compose volume not mounting correctly? (I'm using nginx and certbot with docker)

Viewed 236

I'm trying to get certbot docker container to work with my angular/node setup, but Im struggling to mount the requisite shared volumes. I am following the tutorial here and also here but I'm obviously not following something. Here is my docker compose ... the angular/node bit works fine on its own so I won't post the Dockerfiles.

What I think I'm trying to achieve below, is to make the static files within my angular container at path /usr/share/nginx/html available to the certbox container so it can work its magic...

version: '3'
services:

  angular:
    build: angular
    depends_on:
      - nodejs
    ports:
      - "80:80"
    volumes:
      - certbot-etc:/etc/letsencrypt
      - certbot-var:/var/lib/letsencrypt
      - web-root:/usr/share/nginx/html

  certbot:
    image: certbot/certbot
    container_name: certbot
    volumes:
      - certbot-etc:/etc/letsencrypt
      - certbot-var:/var/lib/letsencrypt
      - web-root:/usr/share/nginx/html
    depends_on:
      - angular
    command: certonly --webroot --webroot-path=/usr/share/nginx/html --email ivyterrace@hotmail.co.uk --agree-tos --no-eff-email --staging -d trailscape.cc -d www.trailscape.cc

  nodejs:
    build: nodejs
    volumes:
      - ./data:/data
    ports:
      - "8080:8080"

volumes:
    certbot-etc:
    certbot-var:
    web-root:

The problem I have is mounting the web-root volume .. when I inspect the certbot docker image i get:

            "Volumes": {
                "/etc/letsencrypt": {},
                "/var/lib/letsencrypt": {}
            },

No /usr/share/nginx/html. If I inspect the angular image its even worse:

            "Volumes": null,

But if I view volumes using docker volume ls, I can see the web-root volume:

DRIVER              VOLUME NAME
local               ivyterrace_certbot-etc
local               ivyterrace_certbot-var
local               ivyterrace_web-root

What's going on, why are my named volumes not mounting correctly? The nodejs volume mounts fine.

I've been trying to wkr this out for two days so any pointers appreciated.

1 Answers

It can be permission problem, the first try with sudo(if OS is linux)

Second: try change volumes like this.

 volumes:
      - ../data/certbot-etc:/etc/letsencrypt

Hope your OS is not windows.

Related