【发布时间】:2022-02-22 19:45:01
【问题描述】:
我需要从 Dockerfile 创建一个 docker 映像。我的 Dockerfile 示例如下。
FROM ubuntu:20.04
......
..........
..............
RUN apt install -y aptitude
RUN sh -c '/bin/echo -e "n\ny\ny" | aptitude -f install python-dev'
错误:
Do you want to continue? [Y/n/?] Abort.
The command '/bin/sh -c sh -c '/bin/echo -e "n\ny\ny" | aptitude -f install python-dev'' returned a non-zero code: 1
通过 dockerfile,即使我在下面尝试过。但还是没有成功。
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && DEBIAN_FRONTEND=noninteractive aptitude -f install python-dev
错误:
Do you want to continue? [Y/n/?] n (stdin unavailable)
Abort.
The command '/bin/sh -c apt update && DEBIAN_FRONTEND=noninteractive aptitude -f install python-dev' returned a non-zero code: 1
我的应用程序代码编译有各种依赖项,在 docker 容器中手动我可以使用 aptitude -f install python-dev 包进行安装,没有任何问题。在安装过程中,我需要回答如下安装问题。
aptitude -f install python-dev
no
yes
yes
请给我通过dockerfile回答yes and No问题的解决方案。提前致谢。
【问题讨论】:
-
是要避开提示,还是要回答?
-
我想通过在我的 dockerfile 中找到答案来安装包。
-
(对于这些安装,我建议坚持使用
apt-get;正如@Paolo 的回答和其他一些人建议的那样,使用apt-get install -y选项。不要使用更高级别的工具,例如apt或 Dockerfile 中的aptitude。)
标签: docker dockerfile