I am running a container with docker-py in Python. Similar to the docs:
import docker
client = docker.from_env()
container = client.containers.run('bfirsh/reticulate-splines', detach=True)
The container performs some tasks and saves a .json
file to a shared volume.
Everything is working fine except that I do not know how to catch the container exit when running in the background.
More specifically, my question is the following:
"Is there a way in docker-py to pass a callback function to a container running in detach mode?"
I want to access the saved .json
on exit and avoid using ugly statements like time.sleep()
or iterating while the status is running
.
From the docs it does not seem possible. Do you have any workaround to share?