Pulling missing docker image before doing anything

This commit is contained in:
Ian Babrou 2015-03-22 14:16:02 +03:00 committed by Matt Clay
parent c68d1ffa60
commit 9219aeaaeb

View file

@ -1578,10 +1578,14 @@ def main():
if count > 1 and name: if count > 1 and name:
module.fail_json(msg="Count and name must not be used together") module.fail_json(msg="Count and name must not be used together")
# Explicitly pull new container images, if requested. # Explicitly pull new container images, if requested. Do this before
# Do this before noticing running and deployed containers so that the image names will differ # noticing running and deployed containers so that the image names
# if a newer image has been pulled. # will differ if a newer image has been pulled.
if pull == "always": # Missing images should be pulled first to avoid downtime when old
# container is stopped, but image for new one is now downloaded yet.
# It also prevents removal of running container before realizing
# that requested image cannot be retrieved.
if pull == "always" or (state == 'reloaded' and manager.get_inspect_image() is None):
manager.pull_image() manager.pull_image()
containers = ContainerSet(manager) containers = ContainerSet(manager)