This and the function below should probably go into the docker_daemon.py module.