podman: Call host podman inside a container but encounter `Connection refused` error
I want to call host podman inside a container by podman python client
So I do
-
run a contianer and mount podman socket
podman run -it --privileged --entrypoint=bash -v /lib/systemd/system/io.podman.socket:/lib/systemd/system/io.podman.socket docker.io/python:3.6 -
then I login to the container, install python package
python3 -m pip install podman -
call podman with the socket
unix:/lib/systemd/system/io.podman.socketlike what I did with docker but error shows
python
Python 3.6.9 (default, Sep 12 2019, 16:23:48)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import podman
>>> pclient=podman.Client(uri='unix:/lib/systemd/system/io.podman.socket')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/podman/client.py", line 178, in __init__
if not System(self._client).ping():
File "/usr/local/lib/python3.6/site-packages/podman/libs/system.py", line 38, in ping
with self._client() as podman:
File "/usr/local/lib/python3.6/site-packages/podman/client.py", line 98, in __enter__
self._iface = self._client.open(self._context.interface)
File "/usr/local/lib/python3.6/site-packages/varlink/client.py", line 598, in open
connection = self.open_connection()
File "/usr/local/lib/python3.6/site-packages/varlink/client.py", line 613, in open_connection
return self._socket_fn()
File "/usr/local/lib/python3.6/site-packages/varlink/client.py", line 512, in open_unix
s.connect(address)
ConnectionRefusedError: [Errno 111] Connection refused
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 22 (10 by maintainers)
This should work?