, ,

Speed up Podman build on MacOS and Windows

It has been reported by some users that the podman build command is sometimes slow when run on MacOS and Windows. This is due to the fact that when Podman is used on these operating systems, it actually utilizes a remote client that communicates with a Linux system through the podman REST API service to run containers.

The build command uses a so-called context directory, normally this is your project directory where your Containerfile/Dockerfile is located. However because the actual build is performed on a linux system and build allows you to ADD/COPY files or directories into the new image, Podman needs to copy the full context directory to the server. This is done by tarring the directory on the client and sending to the server which then extracts it again and performs the build. This can be an expensive operation when your context directory is big and also heavily depends on the underlying hardware, i.e. disk speed.

How to fix this

There are two possible ways to fix this problem:

  • Use a .containerignore/.dockerignore file to exclude files/directories that you do not want to copy into the image.
  • If you use a Podman machine setup you can use the `podman machine ssh` command to enter the linux system and perform the build there. This only works when the context directory is on a volume that is mounted into the machine. By default $HOME is mounted so it should work in most cases.

Leave a Reply


Sign up with your email address to receive updates by email from this website.