完整免责声明:我从 docker 开始。
这是我想要实现的目标:构建一个 Ubuntu 20.04 的 docker 镜像,并在其中安装 jvm 和 mariadb。
我在主机(也是 Ubuntu 20.04)上所做的操作:
- sudo apt-get 安装 docker.io
- 编辑 Dockerfile 如下:
FROM ubuntu:20.04
RUN cat /etc/apt/sources.list | grep -v '#' | grep -v '^$'
RUN apt update
- 尝试使用
docker build --no-cache -t pieroxy/ubuntu-test .
以下情况失败了:
Sending build context to Docker daemon 413MB
Step 1/7 : FROM ubuntu:20.04
---> 7e0aa2d69a15
Step 2/7 : RUN cat /etc/apt/sources.list | grep -v '#'
---> Running in adbeec767f3d
deb http://archive.ubuntu.com/ubuntu/ focal main restricted
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ focal universe
deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
deb http://archive.ubuntu.com/ubuntu/ focal multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted
deb http://security.ubuntu.com/ubuntu/ focal-security universe
deb http://security.ubuntu.com/ubuntu/ focal-security multiverse
Removing intermediate container adbeec767f3d
---> fc21ad5fa8f5
Step 3/7 : RUN apt update
---> Running in dbc1b2334efe
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Ign:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Ign:2 http://archive.ubuntu.com/ubuntu focal InRelease
Ign:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Err:4 http://security.ubuntu.com/ubuntu focal-security Release
404 [IP: 91.189.88.142 80]
Ign:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Err:6 http://archive.ubuntu.com/ubuntu focal Release
404 [IP: 91.189.88.152 80]
Err:7 http://archive.ubuntu.com/ubuntu focal-updates Release
404 [IP: 91.189.88.152 80]
Err:8 http://archive.ubuntu.com/ubuntu focal-backports Release
404 [IP: 91.189.88.152 80]
Reading package lists...
E: The repository 'http://security.ubuntu.com/ubuntu focal-security Release' does not have a Release file.
E: The repository 'http://archive.ubuntu.com/ubuntu focal Release' does not have a Release file.
E: The repository 'http://archive.ubuntu.com/ubuntu focal-updates Release' does not have a Release file.
E: The repository 'http://archive.ubuntu.com/ubuntu focal-backports Release' does not have a Release file.
The command '/bin/sh -c apt update' returned a non-zero code: 100
据我所知,我应该能够使用 apt 安装东西。如果没有 Dockerfile 中的最后一行,我可以将容器运行到 bash,但可用的 cli 工具很少,因此很难调查任何东西(vi、nano、ping、curl,默认情况下没有安装任何东西,apt 不起作用)。但执行此操作apt update
会产生相同的错误。
我尝试过/知道的:
- 主机可以访问互联网,不需要代理。
- 无法断言 docker 镜像的互联网访问,因为 ping、curl、wget、telnet 在镜像内部不可用。
- 我在两台机器上遇到了同样的问题:我的主要台式电脑和一家知名欧洲托管服务提供商 OVH 的托管 Ubuntu 服务器。两台主机都可以直接访问互联网。
任何帮助将不胜感激。