Yuday
Yuday

Reputation: 4509

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?

Upvotes: 1

Views: 1017

Answers (3)

Juergen Klasen
Juergen Klasen

Reputation: 829

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

it's always worth to run from the inside of the container a ping x.x.x.x (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

Upvotes: 0

BMW
BMW

Reputation: 45293

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

Upvotes: 1

Chin Lee
Chin Lee

Reputation: 133

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

Upvotes: 0

Related Questions