Docker 当 运行 命令 apt 更新 (tensorflow/tensorflow:1.5.0-devel-gpu-py3) 时容器卡在 0% [工作]
Docker container stuck at 0% [Working] when running command apt update (tensorflow/tensorflow:1.5.0-devel-gpu-py3)
我有 dockerfile:
FROM tensorflow/tensorflow:1.5.0-devel-gpu-py3
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
当我构建它时:
sudo docker build -t tf150image .
运行容器:
sudo docker run -dt --rm --gpus all -v "$(pwd)":/usr/src/app/ -p 8080:5000 --name tf150container tf150image
运行宁bash在容器中:
sudo docker exec -it tf150container /bin/bash
并希望通过以下方式更新它:
apt update
或
apt-get update
但它永远停留在 0% [工作]:
root@db4002b042a8:/usr/src/app# apt-get update
Get:3 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [256 kB]
Get:11 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [2051 kB]
Get:12 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [15.9 kB]
Get:13 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [984 kB]
Get:14 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [8820 B]
Get:15 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [548 kB]
Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [2560 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [16.4 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [1544 kB]
Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [26.2 kB]
Get:22 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [10.9 kB]
Get:23 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [12.7 kB]
0% [Working]
我该如何解决这个问题?
我已经试过了:
1.
apt-get clean
apt-get update
- 在下次尝试构建映像之前:
sudo docker image prune -a
- 将 /etc/apt/sources.list 替换为在 https://repogen.simplylinux.ch/:
处生成的列表
#------------------------------------------------------------------------------#
# OFFICIAL UBUNTU REPOS #
#------------------------------------------------------------------------------#
###### Ubuntu Main Repos
deb http://pl.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://pl.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
###### Ubuntu Update Repos
deb http://pl.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://pl.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://pl.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://pl.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://pl.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://pl.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://pl.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://pl.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
###### Ubuntu Partner Repo
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
但它给出了以下输出:
root@db4002b042a8:/usr/src/app# apt-get update
Get:3 http://pl.archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:4 http://pl.archive.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Get:5 http://archive.canonical.com/ubuntu xenial InRelease [11.5 kB]
Get:6 http://pl.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:7 http://pl.archive.ubuntu.com/ubuntu xenial-proposed InRelease [260 kB]
Get:8 http://pl.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:9 http://pl.archive.ubuntu.com/ubuntu xenial/main Sources [1103 kB]
Get:10 http://pl.archive.ubuntu.com/ubuntu xenial/restricted Sources [5179 B]
Get:11 http://pl.archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]
Get:12 http://archive.canonical.com/ubuntu xenial/partner Sources [2303 B]
Get:13 http://archive.canonical.com/ubuntu xenial/partner amd64 Packages [2763 B]
Get:14 http://pl.archive.ubuntu.com/ubuntu xenial/multiverse Sources [215 kB]
Get:15 http://pl.archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]
Get:16 http://pl.archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Get:17 http://pl.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Get:18 http://pl.archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]
Get:19 http://pl.archive.ubuntu.com/ubuntu xenial-security/main Sources [311 kB]
Get:20 http://pl.archive.ubuntu.com/ubuntu xenial-security/restricted Sources [3239 B]
Get:21 http://pl.archive.ubuntu.com/ubuntu xenial-security/universe Sources [256 kB]
Get:22 http://pl.archive.ubuntu.com/ubuntu xenial-security/multiverse Sources [4950 B]
Get:23 http://pl.archive.ubuntu.com/ubuntu xenial-security/main amd64 Packages [2051 kB]
Get:24 http://pl.archive.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [15.9 kB]
Get:25 http://pl.archive.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [984 kB]
Get:26 http://pl.archive.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [8820 B]
Get:27 http://pl.archive.ubuntu.com/ubuntu xenial-updates/main Sources [665 kB]
Get:28 http://pl.archive.ubuntu.com/ubuntu xenial-updates/restricted Sources [3941 B]
Get:29 http://pl.archive.ubuntu.com/ubuntu xenial-updates/universe Sources [548 kB]
Get:30 http://pl.archive.ubuntu.com/ubuntu xenial-updates/multiverse Sources [13.5 kB]
Get:31 http://pl.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [2560 kB]
Get:32 http://pl.archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [16.4 kB]
Get:33 http://pl.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [1544 kB]
Get:34 http://pl.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [26.2 kB]
Get:35 http://pl.archive.ubuntu.com/ubuntu xenial-proposed/main Sources [3596 B]
Get:36 http://pl.archive.ubuntu.com/ubuntu xenial-proposed/universe Sources [2526 B]
Get:37 http://pl.archive.ubuntu.com/ubuntu xenial-proposed/main amd64 Packages [31.7 kB]
Get:38 http://pl.archive.ubuntu.com/ubuntu xenial-proposed/universe amd64 Packages [2393 B]
Get:39 http://pl.archive.ubuntu.com/ubuntu xenial-backports/main Sources [7276 B]
Get:40 http://pl.archive.ubuntu.com/ubuntu xenial-backports/universe Sources [12.3 kB]
Get:41 http://pl.archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [10.9 kB]
Get:42 http://pl.archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [12.7 kB]
0% [Working]
- 当我使用其他父图像时,例如:
FROM python:3.6-buster
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
那我用apt-get update一点问题都没有。
这很奇怪,因为几个月前,我已经能够毫无问题地使用同一个 dockerfile 完成它。
在 FROM tensorflow/tensorflow:1.5.0-devel-gpu-py3
之后添加这一行对我来说是这样的:
RUN rm /etc/apt/sources.list.d/* && apt clean && apt update
您最终的 dockerfile 应该如下所示:
FROM tensorflow/tensorflow:1.5.0-devel-gpu-py3
RUN rm /etc/apt/sources.list.d/* && apt clean && apt update
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
我有 dockerfile:
FROM tensorflow/tensorflow:1.5.0-devel-gpu-py3
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
当我构建它时:
sudo docker build -t tf150image .
运行容器:
sudo docker run -dt --rm --gpus all -v "$(pwd)":/usr/src/app/ -p 8080:5000 --name tf150container tf150image
运行宁bash在容器中:
sudo docker exec -it tf150container /bin/bash
并希望通过以下方式更新它:
apt update
或
apt-get update
但它永远停留在 0% [工作]:
root@db4002b042a8:/usr/src/app# apt-get update
Get:3 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [256 kB]
Get:11 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [2051 kB]
Get:12 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [15.9 kB]
Get:13 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [984 kB]
Get:14 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [8820 B]
Get:15 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [548 kB]
Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [2560 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [16.4 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [1544 kB]
Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [26.2 kB]
Get:22 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [10.9 kB]
Get:23 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [12.7 kB]
0% [Working]
我该如何解决这个问题?
我已经试过了:
1.
apt-get clean
apt-get update
- 在下次尝试构建映像之前:
sudo docker image prune -a
- 将 /etc/apt/sources.list 替换为在 https://repogen.simplylinux.ch/: 处生成的列表
#------------------------------------------------------------------------------#
# OFFICIAL UBUNTU REPOS #
#------------------------------------------------------------------------------#
###### Ubuntu Main Repos
deb http://pl.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://pl.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
###### Ubuntu Update Repos
deb http://pl.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://pl.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://pl.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://pl.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://pl.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://pl.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://pl.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://pl.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
###### Ubuntu Partner Repo
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
但它给出了以下输出:
root@db4002b042a8:/usr/src/app# apt-get update
Get:3 http://pl.archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:4 http://pl.archive.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Get:5 http://archive.canonical.com/ubuntu xenial InRelease [11.5 kB]
Get:6 http://pl.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:7 http://pl.archive.ubuntu.com/ubuntu xenial-proposed InRelease [260 kB]
Get:8 http://pl.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:9 http://pl.archive.ubuntu.com/ubuntu xenial/main Sources [1103 kB]
Get:10 http://pl.archive.ubuntu.com/ubuntu xenial/restricted Sources [5179 B]
Get:11 http://pl.archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]
Get:12 http://archive.canonical.com/ubuntu xenial/partner Sources [2303 B]
Get:13 http://archive.canonical.com/ubuntu xenial/partner amd64 Packages [2763 B]
Get:14 http://pl.archive.ubuntu.com/ubuntu xenial/multiverse Sources [215 kB]
Get:15 http://pl.archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]
Get:16 http://pl.archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Get:17 http://pl.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Get:18 http://pl.archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]
Get:19 http://pl.archive.ubuntu.com/ubuntu xenial-security/main Sources [311 kB]
Get:20 http://pl.archive.ubuntu.com/ubuntu xenial-security/restricted Sources [3239 B]
Get:21 http://pl.archive.ubuntu.com/ubuntu xenial-security/universe Sources [256 kB]
Get:22 http://pl.archive.ubuntu.com/ubuntu xenial-security/multiverse Sources [4950 B]
Get:23 http://pl.archive.ubuntu.com/ubuntu xenial-security/main amd64 Packages [2051 kB]
Get:24 http://pl.archive.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [15.9 kB]
Get:25 http://pl.archive.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [984 kB]
Get:26 http://pl.archive.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [8820 B]
Get:27 http://pl.archive.ubuntu.com/ubuntu xenial-updates/main Sources [665 kB]
Get:28 http://pl.archive.ubuntu.com/ubuntu xenial-updates/restricted Sources [3941 B]
Get:29 http://pl.archive.ubuntu.com/ubuntu xenial-updates/universe Sources [548 kB]
Get:30 http://pl.archive.ubuntu.com/ubuntu xenial-updates/multiverse Sources [13.5 kB]
Get:31 http://pl.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [2560 kB]
Get:32 http://pl.archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [16.4 kB]
Get:33 http://pl.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [1544 kB]
Get:34 http://pl.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [26.2 kB]
Get:35 http://pl.archive.ubuntu.com/ubuntu xenial-proposed/main Sources [3596 B]
Get:36 http://pl.archive.ubuntu.com/ubuntu xenial-proposed/universe Sources [2526 B]
Get:37 http://pl.archive.ubuntu.com/ubuntu xenial-proposed/main amd64 Packages [31.7 kB]
Get:38 http://pl.archive.ubuntu.com/ubuntu xenial-proposed/universe amd64 Packages [2393 B]
Get:39 http://pl.archive.ubuntu.com/ubuntu xenial-backports/main Sources [7276 B]
Get:40 http://pl.archive.ubuntu.com/ubuntu xenial-backports/universe Sources [12.3 kB]
Get:41 http://pl.archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [10.9 kB]
Get:42 http://pl.archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [12.7 kB]
0% [Working]
- 当我使用其他父图像时,例如:
FROM python:3.6-buster
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
那我用apt-get update一点问题都没有。
这很奇怪,因为几个月前,我已经能够毫无问题地使用同一个 dockerfile 完成它。
在 FROM tensorflow/tensorflow:1.5.0-devel-gpu-py3
之后添加这一行对我来说是这样的:
RUN rm /etc/apt/sources.list.d/* && apt clean && apt update
您最终的 dockerfile 应该如下所示:
FROM tensorflow/tensorflow:1.5.0-devel-gpu-py3
RUN rm /etc/apt/sources.list.d/* && apt clean && apt update
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app