在容器中找不到“/etc/letsencrypt/live/”

Cannot find `/etc/letsencrypt/live/` in a container

我的服务器与以下 docker-compose.yml 配合良好。我可以在容器 /etc/letsencrypt/live/v2.10studio.tech/fullchain.pem/etc/letsencrypt/live/v2.10studio.tech/privkey.pem.

中找到
version: "3"
services:
  frontend:
    restart: unless-stopped
    image: staticfloat/nginx-certbot
    ports:
      - 80:8080/tcp
      - 443:443/tcp
    environment:
      CERTBOT_EMAIL: owner@company.com
    volumes:
      - ./conf.d:/etc/nginx/user.conf.d:ro
      - letsencrypt:/etc/letsencrypt
  10studio:
    image: bitnami/nginx:1.16
    restart: always
    volumes: 
      - ./build:/app
      - ./default.conf:/opt/bitnami/nginx/conf/server_blocks/default.conf:ro
      - ./configs/config.prod.js:/app/lib/config.js
    depends_on: 
    - frontend

volumes:
  letsencrypt:

networks:
  default:
    external:
      name: 10studio

我尝试创建另一个具有相同设置的服务器,但在容器的 /etc/letsencrypt 下找不到 live

有谁知道这是怎么回事? /etc/letsencrypt/live 下的文件来自哪里?

编辑 1:

我有一个文件 conf.d/.conf,我尝试重建并收到以下消息:

root@iZj6cikgrkjzogdi7x6rdoZ:~/10Studio/pfw# docker-compose up --build --force-recreate --no-deps
Creating pfw_pfw_1 ... done
Creating pfw_10studio_1 ... done
Attaching to pfw_pfw_1, pfw_10studio_1
10studio_1  |  11:25:33.60 
10studio_1  |  11:25:33.60 Welcome to the Bitnami nginx container
pfw_1       | templating scripts from /etc/nginx/user.conf.d to /etc/nginx/conf.d
pfw_1       | Substituting variables 
pfw_1       |  -> /etc/nginx/user.conf.d/*.conf
pfw_1       | /scripts/util.sh: line 116: /etc/nginx/user.conf.d/*.conf: No such file or directory
pfw_1       | Done with startup
pfw_1       | Run certbot
pfw_1       | ++ parse_domains
pfw_1       | ++ for conf_file in /etc/nginx/conf.d/*.conf*
pfw_1       | ++ xargs echo
pfw_1       | ++ sed -n -r -e 's&^\s*ssl_certificate_key\s*\/etc/letsencrypt/live/(.*)/privkey.pem;\s*(#.*)?$&&p' /etc/nginx/conf.d/certbot.conf
pfw_1       | + auto_enable_configs
pfw_1       | + for conf_file in /etc/nginx/conf.d/*.conf*
pfw_1       | + keyfiles_exist /etc/nginx/conf.d/certbot.conf
pfw_1       | ++ parse_keyfiles /etc/nginx/conf.d/certbot.conf
pfw_1       | ++ sed -n -e 's&^\s*ssl_certificate_key\s*\(.*\);&&p' /etc/nginx/conf.d/certbot.conf
pfw_1       | + return 0
pfw_1       | + '[' conf = nokey ']'
pfw_1       | + set +x
10studio_1  |  11:25:33.60 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-nginx
10studio_1  |  11:25:33.61 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-nginx/issues
10studio_1  |  11:25:33.61 Send us your feedback at containers@bitnami.com
10studio_1  |  11:25:33.61 
10studio_1  |  11:25:33.62 INFO  ==> ** Starting NGINX setup **
10studio_1  |  11:25:33.64 INFO  ==> Validating settings in NGINX_* env vars...
10studio_1  |  11:25:33.64 INFO  ==> Initializing NGINX...
10studio_1  |  11:25:33.65 INFO  ==> ** NGINX setup finished! **
10studio_1  | 
10studio_1  |  11:25:33.66 INFO  ==> ** Starting NGINX **

如果我docker-compose up -d --build,我仍然无法在容器中找到/etc/letsencrypt/live

请通过original site of this image staticfloat/nginx-certbot,它将创建并自动更新网站 SSL 证书。

使用./conf.d

下的配置文件

为您的自定义配置创建配置目录:

$ mkdir conf.d
And a .conf in that directory:

server {
    listen              443 ssl;
    server_name         server.company.com;
    ssl_certificate     /etc/letsencrypt/live/server.company.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/server.company.com/privkey.pem;

    location / {
        ...
    }
}

因为 /etc/letsencrypt 是从持久卷挂载的 letsencrypt

services:
  frontend:
    restart: unless-stopped
    image: staticfloat/nginx-certbot
    ...
    volumes:
      ...
      - letsencrypt:/etc/letsencrypt

volumes:
  letsencrypt:

如果您需要参考 /etc/letsencrypt/live,您还需要将相同的卷 letsencrypt 装载到您的新应用程序中

由于 /etc/letsencrypt 是一个挂载的卷,它在您的容器重新启动后仍然存在,我假设任何进程都将这些文件添加到卷中。根据使用我最喜欢的搜索引擎的快速搜索,/etc/letsencrypt/live 创建证书后充满了文件

ports: - 80:8080/tcp改成ports: - 80:80/tcp就可以了。