Docker compose apt命令未运行

时间:2020-10-15 17:04:46

标签: docker docker-compose containers certbot

我的docker-compose.yaml中有这部分:

  certbot:
    image: certbot/certbot
    volumes:
      - ./certbot/conf:/etc/letsencrypt
      - ./certbot/www:/var/www/certbot
      command: apt-get update && apt-get install python-certbot-nginx

否则,certbot不会启动证书创建。当我运行docker-compose up时,文件中的其他容器正常运行,但是certbot容器失败并出现以下错误:

certbot_1   | Certbot can obtain and install HTTPS/TLS/SSL certificates.  By default,
certbot_1   | it will attempt to use a webserver both for obtaining and installing the
certbot_1   | certificate.
certbot_1   | certbot: error: unrecognized arguments: apt-get update && apt-get python-certbot-nginx
base_1      |
chatwoot_certbot_1 exited with code 2

请注意,第二个命令缺少安装。如果我更改了其他任何内容(例如删除apt-get更新),则更改会反映在错误日志中,但命令永远不会运行。

尝试使用Dockerfile运行命令,docker-compose.yaml相关部分如下所示:

  certbot:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - ./certbot/conf:/etc/letsencrypt
      - ./certbot/www:/var/www/certbot

和Dockerfile:

FROM certbot/certbot
RUN apt-get update && apt-get install -y python-certbot-nginx

错误现在是这样的:

Building certbot
Step 1/2 : FROM certbot/certbot
 ---> 0091bcdbf8c6
Step 2/2 : RUN apt-get update && apt-get install -y python-certbot-nginx
 ---> Running in 64119cd99255
/bin/sh: apt-get: not found
ERROR: Service 'certbot' failed to build : The command '/bin/sh -c apt-get update && apt-get install -y python-certbot-nginx' returned a non-zero code: 127

有什么建议吗?

0 个答案:

没有答案