Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container is not deleted if detach=True and remove=True are specified #402

Open
landgraf opened this issue Jun 24, 2024 · 2 comments
Open

Comments

@landgraf
Copy link

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

@landgraf landgraf changed the title remove option of containers.run doesn't have any effect Container is not deleted if remove=True specified Jun 24, 2024
@inknos inknos changed the title Container is not deleted if remove=True specified Container is not deleted if detach=True and remove=True are specified Jul 29, 2024
@inknos
Copy link
Contributor

inknos commented Jul 29, 2024

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

@inknos
Copy link
Contributor

inknos commented Jul 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants