I'm trying to run a locally built container using podman as root. Note this is purely for a development environment, and I'm aware that running containers as root is bad.
i.e.
sudo podman run -it <image>
However since the image exists under ~/.local for the current user podman fails to see find it.
So I tried pointing podman at the users container storage area
sudo podman run -it <image> --root /home/<username>/.local/share/containers/storage
This fails
Error: error creating libpod runtime: database libpod temporary files directory (tmpdir) "/run/user/1000/libpod/tmp" does not match our libpod temporary files directory (tmpdir) "/var/run/libpod": database configuration mismatch
So I tried again,
sudo podman run -it <image> \
--root /home/<username>/.local/share/containers/storage \
--tmpdir /run/user/1000/libpod/tmp \
--runroot /run/user/1000
This actually works but causes files to be left behind in which only root can access. This means subsequent calls to non-sudo podman fail.
My other workaround consisted of transferring the image from the user to root before running
podman save <image> | sudo podman load
sudo podman run <image>
The root user uses the configuration /etc/containers/storage.conf
, this can be amended to include the non-root users image store. See https://www.redhat.com/sysadmin/image-stores-podman
additionalimagestores = [
"/home/<username>/.local/share/containers/storage"
]
Credit to @ErikSjölund for pointing this out.