在dockerfile中升级gcc

时间:2015-12-29 01:26:34

标签: docker dockerfile

我正在尝试从docker文件构建一个docker镜像,有时我在dockerfile中运行这个命令

91 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 65.3 MB of archives.
After this operation, 7098 kB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
The command '/bin/sh -c apt-get upgrade gcc' returned a non-zero code: 1

当我构建图像时,它将到达此点,然后停止使用

下面的输出构建图像
{{1}}

1 个答案:

答案 0 :(得分:3)

apt-get upgrade尝试从标准输入流中读取用户输入,这在Docker构建期间不可用。您可以使用apt-get(或-y--yes)标记强制--assume-yes进入非交互模式:

RUN apt-get upgrade -y gcc

来自the manpage

  

-y--yes--assume-yes

     

自动提示是。假设“是”作为所有提示的答案并以非交互方式运行。如果发生不良情况,例如更换保留的包裹或移除基本包裹,则apt-get将中止。