Skip to content
Home ยป Solved: “docker build” hangs

Solved: “docker build” hangs

Tags:

Taking a Docker course, building your first image and nothing happens? Here’s why and how to solve this issue.

When you run the docker build command, the Docker client will send the “context” of your Dockerfile via REST to the Docker daemon. This “context” is the content of what is in the directory of where you created the Dockerfile. In other words, Docker client is scanning all files and folders. Now, if your folder is huge this can take a while — e.g. c:/Users/yourname.

To solve this problem, there are multiple things you can do. You can simply create a new directory and place your Dockerfile in it. However, if that’s not an option, you can create a .dockerignore file.

Let’s say you want to exclude your default Windows folder. You could add all the folders manually, like this:

AppData
Contacts
Desktop
Documents
Downloads
Favorites
Google Drive
Links
...

However, you can simply exclude all the directories within the root where you placed the Dockerfile. This can be done using the special wildcard string, which will simply match all directories.

**

Finally, let’s say you want to exclude all folders, except for one in particular, you can use an exclamation mark to create exceptions, like this.

**
!my_folder

Good luck!

Say thanks, ask questions or give feedback

Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.

2 thoughts on “Solved: “docker build” hangs”

Leave a Reply

Your email address will not be published. Required fields are marked *