简体   繁体   English

docker build尝试安装ubuntu软件包失败

[英]`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.

相关问题 在OSx上Docker安装失败 - Docker install fails on OSx Docker构建的Ubuntu 16.04映像失败-连接失败,返回了非零代码:100 - Docker build of Ubuntu 16.04 image fails - Connection failed, returned a non-zero code: 100 如何查找和安装与MacOS软件包等效的Ubuntu 18.04软件包 - How to find and install Ubuntu 18.04 packages that are equivalent to MacOS packages npm install odbc在OSX和Ubuntu上失败 - npm install odbc fails on OSX and Ubuntu 在尝试安装 ocaml-compiler 以及所需的包时如何解决这些错误? (终端说构建 cmdliner,topkg 失败) - how can I solve these errors while trying to install the ocaml-compiler as well as required packages? (terminal says build cmdliner, topkg failed) Jenkins 构建步骤在“npm 安装”时失败<whatever> &#39; - Jenkins build step fails on 'npm install <whatever>' pip无法在Mac上的Docker容器内安装软件包 - pip unable to install packages inside docker container on mac Docker - Mac OSX Ubuntu 在 apt-get 更新时失败 - Docker - Mac OSX Ubuntu fails on apt-get update Android gradle 在 ADO 上的 ubuntu 代理上构建失败,但在 Windows 上编译,macos - Android gradle build fails on ubuntu agents on ADO but compiles on Windows, macos 尝试在 macOS 上安装 Unity AndroidPlayer 时安装失败 - Installation fails when trying to install Unity AndroidPlayer on macOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM