在Docker构build期间从Dockerfile使用STDIN

我试图在Docker镜像中安装Miniconda作为第一步,现在就是我所拥有的:

FROM ubuntu:14.04 RUN apt-get update && apt-get install wget RUN wget *miniconda download URL* && bash file_downloaded.sh 

当我尝试构build图像时,它会一直运行,直到它开始不断popup以下消息: >>>请回答“是”或“否”此时,我需要停止Docker构build。 我该如何解决? 我应该在dockerfile中包含一些东西吗?

我相信你可以通过-b标志到miniconda shell脚本来避免手动应答

 Installs Miniconda3 4.0.5 -b run install in batch mode (without manual intervention), it is expected the license terms are agreed upon -f no error if install prefix already exists -h print this help message and exit -p PREFIX install prefix, defaults to $PREFIX 

像这样的东西:

 RUN wget http://......-x86_64.sh -O miniconda.sh RUN chmod +x miniconda.sh \ && bash ./miniconda.sh -b 

在图像构build过程中,您不能附加交互式tty。 如果在软件包安装过程中询问是“yes”还是“no”,那么在你的情况下,你可以使用RUN apt-get update -qq && apt-get install -y wgetreplace相应的行。 如果是bash file_downloaded.sh ,请检查file_downloaded.sh接受“是”或“否”作为命令行参数。

如果file_downloaded.sh没有这个选项,请从ubuntu:14.04镜像创build一个容器,安装wget并在那里手动运行你的命令。 然后,您可以通过提交您的更改,如: docker commit <cotainer_id> <image_name>来创build容器的映像。