mrkre
mrkre

Reputation: 1548

Docker build slow on EC2 (Amazon Linux)

I provisioned an instance from Amazon Machine Image based on Amazon Linux (amzn-ami-2016.03.c-amazon-ecs-optimized). While attempting to do a docker build for my project, I find the process extremely slow, even for simple tasks like setting environment variables ENV TEST_PORT=3000 etc. A build that takes less than 5 minutes on my local machine has been running for at least an hour.

Running docker info returns Storage as devicemapper and this article suggests switching to aufs but it is for Ubuntu. I also have an EBS volume attached to my instance, how do I switch docker to use that instead? Will that fix this problem?

Upvotes: 2

Views: 1659

Answers (1)

JayMore
JayMore

Reputation: 221

I experienced the same problem : each simple step of the Dockerfile (like ENV or ARG) is taking one or twe seconds on my Amazon Linux EC2 box. To solve this, I have to :

  • upgrade Docker to version 17.03.2-ce
  • switch the overlay driver of docker, as suggested by https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/ . There is a dedicated section for CentOS.
  • I created /etc/docker/daemon.json with the following content :

    { "storage-driver": "overlay2", "storage-opts": [ "overlay2.override_kernel_check=true" ] }

  • stop and start the docker daemon.

Now each simple step are very fast.

Upvotes: 1

Related Questions