ubuntu - Docker 镜像 Ubuntu 14.04 未连接互联网

标签 ubuntu syntax docker dockerfile

我已经使用 dockerfile 在图像 docker 上安装了 ubuntu 14:04

在我的 dockerfile 中,需要在 ubuntu 中更新和安装应用程序

在 dockerfile 我填写如下语法

# get Ubuntu 14.04 images
FROM ubuntu:14.04

# copy file on local to images
COPY erp-enterprise_revisi.tar.gz /home/

# Update repository
RUN apt-get update

# Install mc on Ubuntu 14.04
RUN apt-get install mc

但是这个错误
Sending build context to Docker daemon 1.236 GB
Step 1 : FROM ubuntu:14.04
 ---> e9ae3c220b23
Step 2 : COPY erp-enterprise_revisi.tar.gz /home/
 ---> d94e66b9d23f
Removing intermediate container babeb959ae8e
Step 3 : RUN apt-get update
 ---> Running in ac702e7d10f4
Err http://archive.ubuntu.com trusty InRelease
Err http://archive.ubuntu.com trusty-updates InRelease
Err http://archive.ubuntu.com trusty-security InRelease
Err http://archive.ubuntu.com trusty Release.gpg
  Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-updates Release.gpg
  Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-security Release.gpg
  Could not resolve 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease  
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease  
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/InRelease  
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg  Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg  Could not resolve 'archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
 ---> 2093977bf1d3
Removing intermediate container ac702e7d10f4
Step 4 : RUN apt-get install mc
 ---> Running in c38aa81084f4
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package mc
The command '/bin/sh -c apt-get install mc' returned a non-zero code: 100

如何连接到互联网?

最佳答案

在第 3 层 (RUN apt-get update) 的环境中构建时,会出现一些网络错误。

当您仅在第 4 层编辑 Dockerfile 时,docker build使用了缓存层,对于第 1~3 层没有再次构建。

您需要使用 -no-cache 重新构建它

所以尝试以下方法:

$ cat Dockerfile

# get Ubuntu 14.04 images
FROM ubuntu:14.04

# copy file on local to images
#COPY erp-enterprise_revisi.tar.gz /home/

# Update repository
RUN apt-get update

# Install mc on Ubuntu 14.04
RUN apt-get install -y mc         <== Here you need give -y to force the install

$ docker build -no-cache -t test .

引用:Best practices for writing Dockerfiles - Build cache

关于ubuntu - Docker 镜像 Ubuntu 14.04 未连接互联网,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34034467/

相关文章:

cloud - LXC 与 VM 的典型用例是什么?

powershell - 如何在 Ubuntu 18.04 上将 Powershell Core 更新到最新版本

windows - WoeUSB 创建可启动 USB 不起作用

linux - 如何检查Ubuntu中是否安装了NFS Server?

ubuntu - 拥有 Emacs "always on top"

R-Project if else 语法

sql - 在 SQL 中编写左/右 JOIN 时是否使用 OUTER 关键字?

regex - vimscript 正则表达式字符串中的 + 符号是什么意思

php - Docker-Compose 使用 PHP (MySQLi) 连接 MySQL 数据库

docker - 无法连接到主机VM上的SQL Server Express容器