如何解决Docker compose apt命令未运行
我的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
有什么建议吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。