Reputation: 397
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
commandDoes anyone else suffer from this issue?
Upvotes: 6
Views: 16411
Reputation: 14264
Ensure you have a .dockerignore
file excluding any bulky dev or build packages. In my case I was building a node js project and docker build was choking on node_modules
.
Upvotes: 0
Reputation: 95
My situation was solved by the hint from Fco's answer above.
Basically, I was not mindful of my build context size. I had a git submodule that gathered a lot of data after usage that was bloating the build context.
The solution was to include this (and other directories and subfolders not essential to the build) in the aforementioned .dockerignore
file.
That would also explain why copying the Dockerfile to a different directory does the trick.
Upvotes: 1
Reputation: 1
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.
Upvotes: -2
Reputation: 307
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.
Upvotes: 7
Reputation: 397
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.
Upvotes: 3