简体   繁体   中英

Docker images Ubuntu 14.04 not connected internet

I've installed ubuntu 14:04 on images docker, using dockerfile

At my dockerfile there is a need to update and install the application in ubuntu

on dockerfile I fill syntax like below

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

When you edit your Dockerfile on layer 4 only, docker build used the cached layers, which didn't build again for layer 1 ~ 3.

You need re-build it with -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

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/

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

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. eg when being started with option '--iptables=false' or similar.

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. if it doesn't work from inside the container but from the docker host, you may have a firewall setup issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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