I need a fast way to check if a containers has exited in a scriptable way. Currently using docker library with python but that creates too much overhead.
docker inspect -f {{.State.Status}} $CONTAINER_PID
Any suggestions?
Try doing it by using the subprocess package (the shell=True
is important):
import subprocess
output = subprocess.check_output(r"docker inspect -f {{.State.Status}} $CONTAINER_PID", shell=True).decode()
print(output)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.