Merge pull request #3947 from chouseknecht/devel

docker_container detach not waiting on container to execute.
This commit is contained in:
Chris Houseknecht 2016-06-13 18:19:09 -04:00 committed by GitHub
commit 43cab8322a

View file

@ -802,7 +802,6 @@ class TaskParameters(DockerBaseClass):
tty='tty',
ports='ports',
environment='env',
dns='dns_servers',
name='name',
entrypoint='entrypoint',
cpu_shares='cpu_shares',
@ -1645,8 +1644,8 @@ class ContainerManager(DockerBaseClass):
self.container_stop(container.Id)
self.container_remove(container.Id)
def fail(self, msg):
self.client.module.fail_json(msg=msg)
def fail(self, msg, **kwargs):
self.client.module.fail_json(msg=msg, **kwargs)
def _get_container(self, container):
'''
@ -1774,6 +1773,13 @@ class ContainerManager(DockerBaseClass):
self.client.start(container=container_id)
except Exception as exc:
self.fail("Error starting container %s: %s" % (container_id, str(exc)))
if not self.parameters.detach:
status = self.client.wait(container_id)
if status != 0:
output = self.client.logs(container_id, stdout=True, stderr=True, stream=False, timestamps=False)
self.fail(output, status=status)
return self._get_container(container_id)
def container_remove(self, container_id, link=False, force=False):