Building images: Podman or Docker
I have a simple use case for building images. I have a Python script that I run from my Synology NAS box as a container using Task Scheduler. I have one task that pulls the image and another to run a container using that image. I create my image using a derived image of Debian from Astral that has uv pre-installed. I call uv run in the image which creates a temporary environment and executes my python script.
The last time I built this image I used docker buildx with the platform flag since I was building it on my M1 MacBook Air. I am now running Asahi Fedora Remix 42 on my MacBook Air which has Podman pre-installed but not Docker. Do I install Docker? Do I use Podman?
Spoiler. It doesn't seem to matter. I looked at this article for reviewing Docker alternatives. I looked into Buildah but then decided it didn't seem to offer anything that Podman didn't. I would later discover that Podman uses Buildah for building images. I was happy I didn't install it after finding that out. After looking at those options, I settled on Podman. I figured at the very least, I wouldn't need to install anything.
I followed most of this article for building images with Podman. It's super simple and ends up being three commands to build the image and push it to my Docker Hub repo.
-
podman build --platform linux/amd64 -t image_name .
Don't forget to include the path to your container or Docker file. The period in my example indicates that the command is being run from the directory with the file. You might not need the platform parameter. I need it since I want the imaage to run on x64 and I'm building on arm64. Be sure that your Dockerfile has a capital D. The above command won't run if the file is dockerfile vs Dockerfile. I think you can also you the file flag to specify the filename. -
podman login docker.io
This is used to log into Docker Hub with your account. You'll need your username and password. You can specify a different registry if you don't use Docker Hub. -
podman push image_name
This command pushes your image to the registry that you signed into in step 2. I haven't seen a way to build and push with one command with Podman like you can with docker buildx.
And that's it! Podman really is a easy replacement of Docker for building and pushing images. After running those three Podman commands, I have a new image in my Docker Hub repo. I could then run my two tasks on my Synology box just like I did when I used docker buildx.