Recently I was trying to migrate from Docker to Podman, the main reason was the ability to build rootless images and run them rootlessly. yet for some unknown reason, the value of my environmental variable DBUS_SESSION_BUS_ADDRESS
is changed to something that podman
does not expect.
See, podman
expects the value of $DBUS_SESSION_BUS_ADDRESS
to be something similar to unix:path=/run/user/1000/bus
while for some reason in my environment, the value is unix:path=/tmp/dbus-fOn17XkgGH,guid=a59ef8224d1e833a07d4a80665807bdb
. You can verify it:
echo $DBUS_SESSION_BUS_ADDRESS
Say, you want to rootless build the following Containerfile
:
FROM docker.io/library/fedora:latest
ENTRYPOINT ["bash"]
It will get built successfully, yet if it has anything that involves writing, it will fail. Consider you want to build the following Containerfile
:
FROM docker.io/library/fedora:latest
RUN echo "Hello world!" > /hello.txt
ENTRYPOINT ["bash"]
If your environmental DBUS_SESSION_BUS_ADDRESS
has a value to something other than what podman
is expecting, you’ll get a similar error:
error running container: from /usr/bin/crun creating container for [/bin/sh -c echo "Hello world!" > /hello.txt]: sd-bus call: Process org.freedesktop.systemd1 exited with status 1: Input/output error: exit status 1
ERRO[0020] did not get container create message from subprocess: EOF⋅
Error: building at STEP "RUN echo "Hello world!" > /hello.txt": while running runtime: exit status 1
To solve this, just give podman
what it expects, by doing:
env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus podman build .
Great, now how to make it permanent? nobody wants to write that everytime he/she wants to build a rootless podman
images. Easy, just make an alias in your shell rc fie. For example in BASH
, you can do:
echo 'alias podman="env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus podman"' >> ~/.bashrc
Then reload it:
source ~/.bashrc
Now everytime you type podman
, it will be replaced with env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus podman
on the fly without you even knowing it. to verify it, type:
type -all podman
Happy linux-ing 😉