[英]`docker build` fails trying to install ubuntu packages
Trying to build a simple ubuntu apache web server docker image, I get an error while the docker build command tries installing packages. 尝试构建一个简单的ubuntu Apache Web服务器docker映像时,当docker build命令尝试安装软件包时出现错误。 I am using the Ubuntu base image in Docker to do this.
我正在Docker中使用Ubuntu基本映像来执行此操作。 Below is the code in my Dockerfile;
以下是我的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"]
My Host OS is Mac OSX El Capitan, and the error I get when the build fails is; 我的主机操作系统是Mac OSX El Capitan,构建失败时出现的错误是:
The command '/bin/sh -c apt-get install apache2' returned a non-zero code: 1
and my docker build command is; 而我的docker build命令是;
docker build -t="webserver" .
Any help please. 请帮忙。 Thanks in Advance.
提前致谢。
You should use the '-y' apt-get flag when building an image. 构建映像时,应使用“ -y” apt-get标志。
apt-get will ask you permission to continue with apache installation, and since you can't interact with the apt-get while building the image, you must pass the '-y' flag that means 'yes' to apt-get prompt. apt-get将询问您是否继续安装apache,并且由于在构建映像时无法与apt-get进行交互,因此必须向apt-get提示符传递“ -y”标志,表示“是”。
Try changing it to: 尝试将其更改为:
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"]
or even: 甚至:
FROM ubuntu
RUN apt-get update && apt-get install apache2 apache2-utils -y
RUN apt-get clean
EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.