docker-py
docker-py copied to clipboard
Usage of auto_remove and remove param
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.
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()