Search code examples
docker-composeweb-deploymentlets-encryptdocker-volumecertbot

Dockerized certbot can not find mounted directory


I'm trying to deploy my service on a vm and I have this part in my docker-compose.yaml:

certbot:
container_name: certbot
image: certbot/certbot:v1.9.0
logging:
  driver: "json-file"
  options:
    max-size: 500m
volumes:
  - {vm_path}/certbot/certbot-etc:/etc/letsencrypt
  - {vm_path}/certbot/certbot-var:/var/lib/letsencrypt
  - {vm_path}/nginx/certbot-web-root:/var/www/certbot/html
  - /etc/localtime:/etc/localtime:ro
  - /etc/timezone:/etc/timezone:ro
command:
  - certonly
  - --webroot
  - -w /var/www/certbot/html
  - --email={email}
  - --agree-tos
  - --no-eff-email
  - --dry-run
  - -d {domain}

but when I run docker-compose up, I get this error from certbot:

certbot | /var/www/certbot/html does not exist or is not a directory

also the directory {vm_path}/nginx/certbot-web-root:/var/www/certbot/html exists on my vm and is absolute.

------UPDATE: My VM's OS is Ubuntu 18.04. I checked docker-compose config and there is no problem in it. Also the result of run ls -l /var/www/certbot:

 certbot        | total 4
 certbot        | drwxr-xr-x    2 1001     1001     4096 Nov  4 10:54 html

and also the /var/www/certbot/html/ exists and is empty.


Solution

  • I've found the answer. The problem is the command section syntax, it should be:

    command:
      - certonly
      - --webroot
      - -w
      - /var/www/certbot/html
      - --email={email}
      - --agree-tos
      - --no-eff-email
      - --dry-run
      - -d
      - {domain}