The Ops Community ⚙️

Joseph D. Marhee
Joseph D. Marhee

Posted on

Using Makefiles to build switching between Podman and Docker automatically

I use a Makefile with most of my projects, and the ones that are packaged as containers, this usually consists of a step like:

docker build -t me/my-project:some-tag
Enter fullscreen mode Exit fullscreen mode

but I recently began using a system that uses Podman by default, so I could alias podman to docker, but more properly, I just updated my Makefile with the following to make the build step conditional and more flexible between hosts:

ifeq ($(shell command -v podman 2> /dev/null),)
    $(CMD) build -t jmarhee/scrivener:$(TAG) . --no-cache
    x11docker --backend=$(CMD) jmarhee/scrivener
Enter fullscreen mode Exit fullscreen mode

where in the above example, it detects not only that I'm running podman, but also updates other configurations that rely on the container runtime as well (in this case, launching a GUI application from the container)

Top comments (0)