I’m trying to migrate one of my dev boxes over from centos 8 to RHEL9. I rely heavily on docker and noticed when I tried to run a docker command on the RHEL box it installed podman-docker. This seemed to go smoothly; I was able to pull an image, launch, build, commit a new version without problem using the docker commands I knew already.
The problem I have encountered though is I can’t seem to interact with it via the docker socket (which seems to be a link to the podman one).
If I run the docker command:
[@rhel9 ~]$ docker images
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/redhat/ubi9 dev_image de371523ca26 6 hours ago 805 MB
docker.io/redhat/ubi9 latest 9ad46cd10362 6 days ago 230 MB
it has my images listed as expected. I should be able to also run:
[@rhel9 ~]$ curl --unix-socket /var/run/docker.sock -H 'Content-Type: application/json' http://localhost/images/json | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3 100 3 0 0 55 0 --:--:-- --:--:-- --:--:-- 55
[]
but as you can see, nothing is coming back. The socket is up and running as I can ping it without issue:
[@rhel9 ~]$ curl -H "Content-Type: application/json" --unix-socket /var/run/docker.sock http://localhost/_ping
OK
I also tried the curl commands using the podman socket directly but it had the same results. Is there something I am missing or a trick to getting it to work so that I can interact with docker/podman via the socket?
2
Answers
I managed to solve my problem although I'm not entirely sure how the scenario came about. I was looking through the output of
docker info
andpodman info
and noticed that they both had the remote socket set as:rather than
/run/podman/podman.sock
which is where I thought it was (this socket does actually exist on my machine). Looking at the systemd file forpodman.socket
I can see that the socket was specified as%t/podman/podman.sock
and checking the man page forpodman-system-service
it specified the rootless socket asunix://$XDG_RUNTIME_DIR/podman/podman.sock
(where my$XDG_RUNTIME_DIR=/run/user/1000
.To get it all working with my software I just needed to make sure the
DOCKER_HOST
env variable was correctly set e.g.export DOCKER_HOST=unix:///run/user/1000/podman/podman.sock
Podman isn’t implemented using a client/server model like Docker. By default there is no socket, because there’s no equivalent to the docker daemon. Podman does provide a compatibility interface that you can use by enabling the
podman.socket
unit:This exposes a Unix socket at
/run/podman/podman.sock
that responds to Docker API commands. But!The socket connects you to
podman
running as root, whereas you’ve been runningpodman
as a non-root user: so you won’t see the same list of images, containers, networks, etc.Some random notes:
root
, in which case the behavior is more like Docker.podman-docker
with the actual Docker client (and use things likedocker-compose
), although I have run into occasional issues with this. Mostly I just use podman, and run docker engine in a VM). You will need to configure Docker to look at the podman socket in/run/podman/podman.sock
.I have
podman.socket
enabled on my system, so this works:Or: