我已经使用 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/