Merge pull request #1031 from smashwilson/docker-wait

[docker] Wait for process exit on detached=no.
reviewable/pr18780/r1
Brian Coca 10 years ago
commit afeb3c8d07

@ -191,7 +191,8 @@ options:
default: null default: null
detach: detach:
description: description:
- Enable detached mode to leave the container running in background. - Enable detached mode to leave the container running in background. If
disabled, fail unless the process exits cleanly.
default: true default: true
state: state:
description: description:
@ -1328,6 +1329,13 @@ class DockerManager(object):
self.client.start(i) self.client.start(i)
self.increment_counter('started') self.increment_counter('started')
if not self.module.params.get('detach'):
status = self.client.wait(i['Id'])
if status != 0:
output = self.client.logs(i['Id'], stdout=True, stderr=True,
stream=False, timestamps=False)
self.module.fail_json(status=status, msg=output)
def stop_containers(self, containers): def stop_containers(self, containers):
for i in containers: for i in containers:
self.client.stop(i['Id']) self.client.stop(i['Id'])

Loading…
Cancel
Save