如何从Dockerfile创build交互图像?

我想从Dockerfile创build一个关于PyQt5的图像。 以下是Dockerfile中的部分代码。

RUN cd PyQt-gpl-5.5.1 &&\ python3 configure.py 

当代码执行时,它会问我: “你接受许可证的条款吗? ,但我无法input任何单词。

而我不想使用命令“提交”。 那么如何从Dockerfile创build一个交互式的图像呢?

如果一个shellpipe道不工作,你可以回退到一个期望的脚本 。

你可以看到一个用在visity/docker-build-android ,在Dockerfile中安装

 RUN dpkg --add-architecture i386 && apt-get update && \ apt-get install -y --force-yes expect ... 

一个tools/android-accept-licenses.sh允许tools/android-accept-licenses.sh在首先接受许可之后构buildtp使用android:

 expect { "Do you accept the license '*'*" { exp_send "y\r" exp_continue } eof } 

它由Dockerfile使用 :

 COPY tools /opt/tools ENV PATH ${PATH}:/opt/tools RUN ["/opt/tools/android-accept-licenses.sh", "android update sdk --all --no-ui --filter platform-tools,tools,build-tools-22.0.1,android-22,addon-google_apis_x86-google-22,extra-android-support,extra-android-m2repository,extra-google-m2repository,sys-img-armeabi-v7a-android-22"] 

这里, android-accept-licenses.sh是COPY到映像的主机/opt/tools一部分,然后在RUN指令中使用。