docker-py only finds podman containers being run as root user

284 Views Asked by At

When using the docker_py library interfacing with a podman daemon, the containers object doesn't seem able to discover containers run by my user, however, are able to discover containers created by the root user.

On my box I have the following:
podman version 4.4.1
py3.9, docker == 6.1.3

for my user I run

podman run --it --rm docker run hello-world

Additionally for my user, at the same time I also run this python snippet.

import docker

self._docker_client: docker.client.DockerClient = docker.from_env()
containers = self._docker_client.containers.list(all=True)
print(f"containers are: {len(containers)}")

The most important thing I notice is that the containers object is empty, even though if I run as my user

podman ps --all

I get results returned.

If I however run the podman run command as the root user, then the python code will return that container.

I'm curious here, is it bad practice to run the docker python library against the podman daemon? I would have thought in the above case that this would have "just worked", however maybe there is something I'm missing here with the namespaces that podman uses?

0

There are 0 best solutions below