Home » Solved: “docker build” hangs

Solved: “docker build” hangs

  • by
docker bay hangs
Tags:
Want to do a random act of kindness? Share this post.

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!

Want to do a random act of kindness? Share this post.