简体   繁体   English

Docker映像Ubuntu 14.04未连接互联网

[英]Docker images Ubuntu 14.04 not connected internet

I've installed ubuntu 14:04 on images docker, using dockerfile 我已经使用dockerfile在镜像docker上安装了ubuntu 14:04

At my dockerfile there is a need to update and install the application in ubuntu 在我的dockerfile中,需要在ubuntu中更新和安装应用程序

on dockerfile I fill syntax like below 在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

But this error 但是这个错误

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

How to connect to the internet? 如何连接到互联网?

When build in your environment at layer 3 ( RUN apt-get update ), there are some network errors. 在第3层环境中RUN apt-get updateRUN apt-get update )时,会出现一些网络错误。

When you edit your Dockerfile on layer 4 only, docker build used the cached layers, which didn't build again for layer 1 ~ 3. 当仅在第4层上编辑Dockerfile时,docker docker build使用了缓存的层,而第1层至第3层则不再构建。

You need re-build it with -no-cache 您需要使用-no-cache重新构建

So try the following: 因此,请尝试以下操作:

$ 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 .

Refer: Best practices for writing Dockerfiles - Build cache 请参阅: 编写Dockerfile的最佳实践-构建缓存

Just found this article, so you should change your repository before install mc, http://slick.pl/kb/linux/installing-midnight-commander-4-8-11-ubuntu-14-04-13-10-13-04-12-04/ 刚刚找到这篇文章,所以您应该在安装mc之前更改存储库, http://slick.pl/kb/linux/installing-midnight-commander-4-8-11-ubuntu-14-04-13-10-13 -04-12-04 /

And in your DockerFile, Replace RUN apt-get install mc to RUN apt-get -y install mc , force to answer yes to avoid non-zero code error 在您的DockerFile中,将RUN apt-get install mc替换为RUN apt-get -y install mc ,强制回答yes以避免非零代码错误

Not that it may apply to this particular case, ... ;-) 并不是说它可能适用于这种特殊情况,... ;-)

... but you will encounter similar symptoms (like the container can't connect to the outside world - eg resolve dns names, resulting to something as this "Could not resolve 'archive.ubuntu.com' " ) when the docker daemon isn't using/applying the needed firewall rules. ...但是您会遇到类似的症状(例如,容器无法连接到外部环境-例如,解析dns名称,导致出现诸如“无法解析'archive.ubuntu.com'“ ),而docker守护进程未启用没有使用/应用所需的防火墙规则。 eg when being started with option '--iptables=false' or similar. 例如,使用选项'--iptables = false'或类似选项启动时。

it's always worth to run from the inside of the container a ping xxxx (like to the google dns 8.8.8.8) to see whether this is reachable. 始终值得从容器内部运行ping xxxx(类似于google dns 8.8.8.8)以查看是否可以访问。 if it doesn't work from inside the container but from the docker host, you may have a firewall setup issue 如果它不是从容器内部而是从Docker主机运行,则可能存在防火墙设置问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM