Docker images Ubuntu 14.04未连接到internet
我已经使用dockerfile在images docker上安装了ubuntu 14:04 在我的dockerfile中,需要在ubuntu中更新和安装应用程序 在dockerfile上,我填充如下语法Docker images Ubuntu 14.04未连接到internet,ubuntu,syntax,docker,dockerfile,Ubuntu,Syntax,Docker,Dockerfile,我已经使用dockerfile在images 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-ge
# 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
如何连接到internet?刚刚找到这篇文章,因此您应该在安装mc之前更改存储库 在你的DockerFile里,
将
运行apt get install mc
替换为运行apt get-y install mc
,强制回答是
以避免非零代码错误当在第3层的环境中构建时(运行apt get update
),会出现一些网络错误
当您仅在第4层上编辑docker文件时,docker build
使用缓存的层,该层不会为第1~3层再次生成
您需要使用-无缓存重新构建它
因此,请尝试以下方法:
$ 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 .
$cat Dockerfile
#获取Ubuntu 14.04图像
来自ubuntu:14.04
#将本地上的文件复制到图像
#复制erp-enterprise_revisi.tar.gz/home/
#更新存储库
运行apt获取更新
#在Ubuntu 14.04上安装mc
运行apt get install-y mc并不是因为它可能适用于此特定情况,…;-)
。。。但是当docker守护进程未使用/应用所需的防火墙规则时,您将遇到类似的症状(例如容器无法连接到外部世界-例如解析dns名称,导致“无法解析'archive.ubuntu.com'”)。
e、 g.使用选项“--iptables=false”或类似选项启动时
从容器内部运行ping x.x.x.x(类似于googledns8.8.8.8)来查看是否可以访问它总是值得的。如果它不能从容器内部工作,而是从docker主机工作,您可能会遇到防火墙设置问题错误,E:找不到包mc命令“/bin/sh-c apt get-y install mc”返回了一个非零代码:100这个错误,先生,当我运行$sudo docker build-no cache-t ubuntu14.04时。错误无法准备上下文:无法计算Dockerfile路径中的符号链接:lstat/home/user/docker/Dockerfile:没有这样的文件或目录。。问题出在哪里?这是你的环境问题,我们无能为力。我的建议是,切换到另一个文件夹,复制Dockerfile,然后重试build命令。