【问题标题】:Docker building image that needs 'y' response需要“y”响应的 Docker 构建映像
【发布时间】:2020-11-12 16:03:03
【问题描述】:

我正在尝试按照 Certbot 网站上的步骤将 Certbot 安装到我的 Nginx 容器中:https://certbot.eff.org/lets-encrypt/pip-nginx

Dockerfile:

FROM nginx:1.17.1

# install wget
RUN apt-get update
RUN apt-get install wget -y

# install certbot
RUN wget https://dl.eff.org/certbot-auto
RUN mv certbot-auto /usr/local/bin/certbot-auto
RUN chown root /usr/local/bin/certbot-auto
RUN chmod 0755 /usr/local/bin/certbot-auto

# get certificate
RUN /usr/local/bin/certbot-auto --nginx -y

# setup automatic renewal
...

我使用 docker-compose 构建图像

$ docker-compose build

构建在“#get certificate”步骤中止

...因为我无法在构建过程中输入“y”?

有没有办法在构建过程中输入“y”?我已经尝试传递 -y 标志,如我的 Dockerfile 中所示,但构建仍然中止。

【问题讨论】:

    标签: docker nginx docker-compose certbot


    【解决方案1】:

    尝试编辑 dockerfile 以将 yes 命令通过管道传输到失败的命令中:

    RUN yes | /usr/local/bin/certbot-auto --nginx -y
    

    yes 命令不断地反复输出y 以及返回键。将其插入命令会导致提示用户输入以y 回答的任何内容。当您无法在脚本中使用--force-y 选项时,通常会使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-18
      • 1970-01-01
      • 2021-09-06
      • 2021-12-06
      • 1970-01-01
      • 2020-04-28
      • 2023-03-30
      相关资源
      最近更新 更多