docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

Usage of auto_remove and remove param

Open Victor725 opened this issue 1 year ago • 1 comments

When using client.containers.run(), we can determine parameters such as image, command, ... I wander what the difference between auto_remove and remove? In Official Document, auto_remove defined as:

auto_remove (bool) – enable auto-removal of the container on daemon side when the container’s process exits.

remove defined as:

remove (bool) – Remove the container when it has finished running. Default: False.

Victor725 avatar Sep 20 '24 03:09 Victor725

The auto_remove option automatically deletes the container when it exits, managed by the Docker daemon, while remove manually removes the container after it finishes running.

In simple terms: auto_remove is handled by the daemon while remove is handled by the code.

container.start()
...
if remove:
    container.remove()

Levii22 avatar Sep 28 '24 11:09 Levii22