@ -1912,13 +1912,17 @@ class ContainerManager(DockerBaseClass):
container = self . _get_container ( self . parameters . name )
container = self . _get_container ( self . parameters . name )
# If the image parameter was passed then we need to deal with the image
# If the image parameter was passed then we need to deal with the image
# version comparison, otherwise we should not care
# version comparison. Otherwise we handle this depending on whether
if self . parameters . image :
# the container already runs or not; in the former case, in case the
# container needs to be restarted, we use the existing container's
# image ID.
image = self . _get_image ( )
image = self . _get_image ( )
self . log ( image , pretty_print = True )
self . log ( image , pretty_print = True )
if not container . exists :
if not container . exists :
# New container
# New container
self . log ( ' No container found ' )
self . log ( ' No container found ' )
if not self . parameters . image :
self . fail ( ' Cannot create container when image is not specified! ' )
new_container = self . container_create ( self . parameters . image , self . parameters . create_parameters )
new_container = self . container_create ( self . parameters . image , self . parameters . create_parameters )
if new_container :
if new_container :
container = new_container
container = new_container
@ -1934,10 +1938,15 @@ class ContainerManager(DockerBaseClass):
self . diff [ ' image_different ' ] = True
self . diff [ ' image_different ' ] = True
self . log ( " differences " )
self . log ( " differences " )
self . log ( differences , pretty_print = True )
self . log ( differences , pretty_print = True )
image_to_use = self . parameters . image
if not image_to_use and container and container . Image :
image_to_use = container . Image
if not image_to_use :
self . fail ( ' Cannot recreate container when image is not specified or cannot be extracted from current container! ' )
if container . running :
if container . running :
self . container_stop ( container . Id )
self . container_stop ( container . Id )
self . container_remove ( container . Id )
self . container_remove ( container . Id )
new_container = self . container_create ( self . parameters . image , self . parameters . create_parameters )
new_container = self . container_create ( image_to_us e, self . parameters . create_parameters )
if new_container :
if new_container :
container = new_container
container = new_container