moby: RUN apt-get update too slow during building an image, on EC2

I am building an image on AWS EC2 (xlarge instance) but it is too slow, running RUN apt-get update takes like hours. The image is based on ubuntu:14.04 image or dockerfile/python image.

Running apt-get update at OS level is normally fast.

I followed this post trying to make it faster, but nothing changes.

The bottleneck looks to be when apt-get logs 12% [Waiting for headers]. Running it from inside the container, this is the output:

$ apt-get -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true update 
0% [Working]GET /ubuntu/dists/trusty/InRelease HTTP/1.1
Host: archive.ubuntu.com
Cache-Control: max-age=0
Accept: text/*
User-Agent: Debian APT-HTTP/1.3 (1.0.1ubuntu2)


HTTP/1.1 404 Not Found
Date: Mon, 22 Dec 2014 05:57:36 GMT
Connection: keep-alive
Transfer-Encoding: chunked

Ign http://archive.ubuntu.com trusty InRelease
12% [Working]GET /ubuntu/dists/trusty-updates/InRelease HTTP/1.1
Host: archive.ubuntu.com
Cache-Control: max-age=0
Accept: text/*
User-Agent: Debian APT-HTTP/1.3 (1.0.1ubuntu2)


12% [Waiting for headers]

Furthermore, the file /etc/apt/source.list of the container is different (pointing to archive.ubuntu.com) compared to the one on the host machine (whose urls point to ec2 servers for ubuntu). But substituting the file /etc/apt/source.list of the host machine with the one from the container, apt-get update on the host machine is still fast.

It looks like there are problems regarding the network, couldn’t find them until now. /etc/resolve.conf of docker container is the same of the host machine.

Suggestions?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Well, I’ve solved changing the image the Dockerfile was based on.