Docker "Build Your Own Image" Example Produces Errors

The example on docker.com produces the following for me. I’m running Docker on Ubuntu 14.04 LTS.

lynd@zdog:~/mydockerbuild$ docker build -t docker-whale .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM docker/whalesay:latest
 ---> ded5e192a685
Step 2 : RUN apt-get -y update && apt-get install -y fortunes
 ---> Running in 9554ed961b2b
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.
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  fortune-mod fortunes-min librecode0
Suggested packages:
  x11-utils bsdmainutils
The following NEW packages will be installed:
  fortune-mod fortunes fortunes-min librecode0
0 upgraded, 4 newly installed, 0 to remove and 3 not upgraded.
Need to get 1961 kB of archives.
After this operation, 4817 kB of additional disk space will be used.
Err http://archive.ubuntu.com/ubuntu/ trusty/main librecode0 amd64 3.6-21
  Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com/ubuntu/ trusty/universe fortune-mod amd64 1:1.99.1-7
  Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com/ubuntu/ trusty/universe fortunes-min all 1:1.99.1-7
  Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com/ubuntu/ trusty/universe fortunes all 1:1.99.1-7
  Could not resolve 'archive.ubuntu.com'
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/r/recode/librecode0_3.6-21_amd64.deb  Could not resolve 'archive.ubuntu.com'

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fortune-mod/fortune-mod_1.99.1-7_amd64.deb  Could not resolve 'archive.ubuntu.com'

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fortune-mod/fortunes-min_1.99.1-7_all.deb  Could not resolve 'archive.ubuntu.com'

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fortune-mod/fortunes_1.99.1-7_all.deb  Could not resolve 'archive.ubuntu.com'

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get -y update && apt-get install -y fortunes' returned a non-zero code: 100

Hi,

This error is just because the docker daemon cannot reach ubuntu apt repositories. Make sure your machine running docker daemon can reach internet.

Regards

Thanks. The machine can reach the Internet. I use apt repositories from it all the time. Maybe the demo needs to be run as sudo? No, that doesn’t fix the errors.

It appears that docker wasn’t able to access a DNS. The Ubuntu 14.04 LTS machine that I have docker installed on is using a dynamic IP number provided by a DHCP server on a LAN. I added the IP of the LAN’s router to the file /etc/default/docker. I suppose I could also provided the IP numbers of some DNS’s. In any case, I was then able to build the example, but I did receive:

[snip]
Get:4 http://archive.ubuntu.com/ubuntu/ trusty/universe fortunes all 1:1.99.1-7 [1089 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 

The example does seen to work, however. Thx!

I have the same issue with Ubuntu 15.10 running in a VM.

All I did to resolve was, vi /etc/resolve.conf
Add the DNS server entry into it.

'nameserver x.x.x.x`