podman-py
podman-py copied to clipboard
Container is not deleted if detach=True and remove=True are specified
remove: Delete container when the container's processes exit. Default: False.
>>> import podman
>>> podman.__version__
'5.0.0'
>>> c = client.containers.run("myimage", detach=True, remove=True, command="/bin/false")
>>> c.status
'exited'
26034e386c92 myimage /bin/false 14 seconds ago Exited (1) 14 seconds ago interesting_williamson
A note:
The following example won't reproduce the issue
from podman import PodmanClient
uri = "unix:///run/user/1000/podman/podman.sock"
with PodmanClient(base_url=uri) as client:
c = client.containers.run("nginx", remove=True, command="/bin/false")
print(c.status)
while
from podman import PodmanClient
uri = "unix:///run/user/1000/podman/podman.sock"
with PodmanClient(base_url=uri) as client:
c = client.containers.run("nginx", deatch=True, remove=True, command="/bin/false")
print(c.status)
will reproduce
Ok, the problem is just that detach is called before remove. I can see how the options can live together, but since I would avoid delegating the removal to the user or threading/scheduling the removal.
Maybe @jwhonce might have something to add about the reasoning behind the code, or if there were some thoughts already on this detach/remove process.