docker - 获取失败:在 ubuntu 上安装 apache Web 服务器时出错
问题描述
我正在尝试构建一个 docker 映像。从 Dockerfile 运行 apache Web 服务器的安装命令时,弹出错误。
注意:我已经在实际文件中添加了 -y 和 apache2-utils 之间的空格。
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/t/tzdata/tzdata_2021a-0ubuntu0.20.04_all.deb 404 Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-bin_2.4.41-4ubuntu3.4_amd64.deb 404 Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-data_2.4.41-4ubuntu3.4_all.deb 404 Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-utils_2.4.41-4ubuntu3.4_amd64.deb 404 Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/a/apache2/apache2_2.4.41-4ubuntu3.4_amd64.deb 404 Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/ca-certificates/ca-certificates_20210119~20.04.1_all.deb 404 Not Found [IP: 91.189.88.152 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get install -y apache2' returned a non-zero code: 100
我尝试运行更新命令并再次构建 Dockerfile,但错误仍然存在。
解决方案
我刚刚使用 Dockerfile 运行了您的示例
FROM ubuntu
MAINTAINER "me"
RUN apt-get update
RUN apt-get install -y apache2
RUN apt-get install -y apache2-utils
RUN apt-get clean
EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]
然后运行docker build .
我没有察觉到您遇到的网络问题,但安装变成了交互式:
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.
1. Africa 4. Australia 7. Atlantic 10. Pacific 13. Etc
2. America 5. Arctic 8. Europe 11. SystemV
3. Antarctica 6. Asia 9. Indian 12. US
Geographic area:
所以你可能想要
- 重新运行您的代码
- 确保 apt-get 不会进行交互
最后一点:apt-get clean
根本不会使您的图像变小。每个都RUN
添加了一个文件系统层,这意味着您将添加一个层来告诉它隐藏文件。为防止这种情况,请将您的调用链接到apt-get
一行RUN
,如下所示:
RUN apt-get update && apt-get install -y apache2 && apt-get install -y apache2-utils && apt-get clean
推荐阅读
- c# - 从字符串数组创建 sql 查询
- r - 将 x 轴限制为当前周
- powershell - 如果输入错误,PowerShell 会获得相同的读取主机
- excel - Excel:删除字符串中的最后一个单词,如果它是一个数字
- python - 是否可以将文件/图像发布到 jupyter 内核网关 API?
- android - BitmapUtils 在从 uri 获取位图时在具有空间的文件夹名称上抛出 FileNotFoundException
- tensorflow - 使用 adanet 预测二元分类问题
- react-native - 反应本机 ios 错误,“可选链”当前未启用
- c++ - 重置动态数组项的默认构造函数
- twitter-bootstrap - 如何修复列中的 Bootstrap 4 内容响应性?