首页 > 解决方案 > 如何回答 dockerfile 中的安装问题?

问题描述

我尝试使用 dockerfile 安装一些东西。但是当我运行命令时,我必须回答如下问题:

进入

6

72

我的dockfile就像下面一样,但似乎不起作用。

FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y expect
RUN apt-get -y install software-properties-common 
RUN apt-add-repository ppa:ondrej/php
expect “Press [ENTER] to continue or Ctrl-c to cancel adding it. ” { send “\n” }
RUN apt-get -y install php7.1 php7.1-fpm 
expect “Please select the geographic area in which you live. ” { send “6\n” }
expect “Please select the city or region corresponding to your time zone. ” { send “72\n” }
RUN -y apt-get install nginx

有人告诉我如何回答 dockerfile 中的安装问题吗?

标签: dockerdockerfile

解决方案


我测试了你的 Dockerfile 并且不需要回答任何问题,但是如果你想在运行命令时自动回答,你可以使用yes(for "y" and "n" 响应) 或echo.

前任:

yes | <YOUR COMMAND>

yes n | <YOUR COMMAND>“n”响应

echo | <YOUR COMMAND>echo 生成新行(回车)

echo "some response" | <YOUR COMMAND>回应“一些回应”


推荐阅读