`docker build` command hangs for a very long time, other commands work fine

Viewed 7275

Simple question: After using Docker for about a week, my docker build command gets bogged down and hangs (before anything executes) for about a minute. After staying in this hanging state, it will execute the docker build command with no issues at all and at at the expected speed.

Other Docker commands (like docker run) do not suffer from this "hanging" issue.

Docker Installation info:

Version 18.06.1-ce-win73
Channel: stable

Things I have tried:

  • docker system prune - This does clear up space, but doesn't speed up my docker build command
  • Reinstalling Docker on my machine - This does fix the issue, but it reappeared after about a week of using Docker again.

Does anyone else suffer from this issue?

3 Answers

Here was the the issue:

The very first line of my Dockerfile (the FROM command) was failing. The "hanging" was caused by a timeout during the attempt to download the base image. I was attempting to download the base image from a location that I needed to set a proxy on my machine for.

So I was mistaken in my original post: The Docker build command wasn't running as expected. It was failing to download the base image due to a missing proxy setting.

I had the same issue. I solved it moving the Dockerfile to an empty folder, then I executed the docker build command and worked perfectly.

On some other forums people created a .dockerignore file including the any call to git and many other files, but that approach didn't work for me.

2 reasons:

1.If you are building many dockers for hours ..please restart your router if possible as sometimes due to heavy data packets movement the router collapses.

2.Increase RAM ,CPU and Swap of docker engine and restart docker and try to build again.

Related