Why are Docker build commands running so slow in Elastic Beanstalk?

EB was complaining that my build was timing out, so I ssh’d into an instance and decided to run docker build myself to see what was happening. Every step, even something as simple as a mkdir takes ages to run. Even a WORKDIR stalls for at least a minute or two before executing.

On my local machine these are instant. What is going on?

  • Where to put ebextensions config in AWS Elastic Beanstalk Docker deploy with dockerrun source bundle?
  • Supervisord in Docker + AWS Elastic Beanstalk can't accept non-alphanumeric environment variables
  • Can I specify a file instead of a directory to send to the container in the Dockerrun.aws.json file?
  • Deploying Docker Data Volumes
  • How install the Amazon ECS Container Agent in Debian? (ecs-init)
  • ECS Docker Container get env variable running cron
  • How to access Docker from outside the machine its hosted on?
  • Remote Debugging From Local to Remote Host Docker Container
  • Host Global Python Object in Docker Container
  • Automatic restart after crash on Google Container Engine
  • Running Boot2Docker on windows, can't connect to the VM ip
  • Why is Dockerized Hadoop datanode registering with the wrong IP address?
  • 2 Solutions collect form web for “Why are Docker build commands running so slow in Elastic Beanstalk?”

    Same issue here with an Ubuntu machine running on AWS. Turns out the the key to the solution was switching from devicemapper to aufs storage backend.

    First, run the following command to figure out which storage backend your currently use:

    docker info | grep Storage

    If it says devicemapper, you probably found the reason for the slowness.

    Here is the prodecure for switching to the aufs backend in Ubuntu, taken from here:

    1. sudo apt-get install -y -q linux-image-extra-$(uname -r)
    2. sudo service docker restart

    Note that you will have to rebuild all your existing images / containers, as they will be wiped when you switch to aufs.

    Sorry to know you are facing this issue.
    Elastic Beanstalk environment creation involves creation of lots of resources like autoscaling group, EC2 instances, security groups, Elastic Load Balancer etc. After that software is installed on your beanstalk instances. I am assuming you are only talking about the slowness of software installation (docker build) on beanstalk.

    If you just run mkdir that should not be very slow. It should be reasonably fast.

    However if you think that docker build overall is running very slow that could be because of IO intensive operations.

    One thing you can try is using EBS provisioned IOPs with Elastic Beanstalk.
    Read more about SSD instances here.

    Can you try launching a new environment with SSD instances and see if docker build is still slow? If you can show an example dockerfile that takes a long time to build, I can try it out.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.