docker build`尝试安装ubuntu软件包失败
试图build立一个简单的Ubuntu的Apache Web服务器docker的形象,我得到一个错误,而dockerbuild设命令尝试安装包。 我正在使用Docker中的Ubuntu基本映像来执行此操作。 以下是我的Dockerfile中的代码;
FROM ubuntu RUN apt-get update RUN apt-get install apache2 RUN apt-get install apache2-utils RUN apt-get clean EXPOSE 80 CMD ["apache2ctl", "-D", "FOREGROUND"]
我的主机操作系统是Mac OSX El Capitan,并且在构build失败时得到的错误是;
The command '/bin/sh -c apt-get install apache2' returned a non-zero code: 1
和我的dockerbuild设命令是;
docker build -t="webserver" .
请任何帮助。 提前致谢。
构build图像时,应该使用“-y”apt-get标志。
apt-get会要求你继续进行apache安装,因为你不能在构build镜像的时候和apt-get进行交互,所以你必须把'-y'标志传递给apt-get提示符。
尝试将其更改为:
FROM ubuntu RUN apt-get update RUN apt-get install apache2 -y RUN apt-get install apache2-utils -y RUN apt-get clean EXPOSE 80 CMD ["apache2ctl", "-D", "FOREGROUND"]
甚至:
FROM ubuntu RUN apt-get update && apt-get install apache2 apache2-utils -y RUN apt-get clean EXPOSE 80 CMD ["apache2ctl", "-D", "FOREGROUND"]