mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 20:08:41 +00:00
docker_container: return status also when 0 for non-detached containers (#58)
* Return status also when 0. * Fix PR number.
This commit is contained in:
parent
9b131399ce
commit
e4b747d788
@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- "docker_container - when a container is started with ``detached=false``, ``status`` is now also returned when it is 0 (https://github.com/ansible-collections/community.docker/issues/26, https://github.com/ansible-collections/community.docker/pull/58)."
|
||||
@ -1136,6 +1136,13 @@ container:
|
||||
},
|
||||
...
|
||||
}'
|
||||
status:
|
||||
description:
|
||||
- In case a container is started without detaching, this contains the exit code of the process in the container.
|
||||
- Before community.docker 1.1.0, this was only returned when non-zero.
|
||||
returned: when I(state) is C(started) and I(detached) is C(false), and when waiting for the container result did not fail
|
||||
type: int
|
||||
sample: 0
|
||||
'''
|
||||
|
||||
import os
|
||||
@ -3007,6 +3014,9 @@ class ContainerManager(DockerBaseClass):
|
||||
status = self.client.wait(container_id)['StatusCode']
|
||||
else:
|
||||
status = self.client.wait(container_id)
|
||||
self.client.fail_results['status'] = status
|
||||
self.results['status'] = status
|
||||
|
||||
if self.parameters.auto_remove:
|
||||
output = "Cannot retrieve result as auto_remove is enabled"
|
||||
if self.parameters.output_logs:
|
||||
@ -3023,7 +3033,7 @@ class ContainerManager(DockerBaseClass):
|
||||
output = "Result logged using `%s` driver" % logging_driver
|
||||
|
||||
if status != 0:
|
||||
self.fail(output, status=status)
|
||||
self.fail(output)
|
||||
if self.parameters.cleanup:
|
||||
self.container_remove(container_id, force=True)
|
||||
insp = self._get_container(container_id)
|
||||
|
||||
@ -588,9 +588,11 @@
|
||||
# often enough to be annoying. That's why we disable this for now,
|
||||
# and simply test that 'Output' is contained in the result.
|
||||
- "'Output' in detach_no_cleanup.container"
|
||||
- detach_no_cleanup.status == 0
|
||||
# - "'Hello from Docker!' in detach_no_cleanup.container.Output"
|
||||
- detach_no_cleanup_cleanup is changed
|
||||
- "'Output' in detach_cleanup.container"
|
||||
- detach_cleanup.status == 0
|
||||
# - "'Hello from Docker!' in detach_cleanup.container.Output"
|
||||
- detach_cleanup_cleanup is not changed
|
||||
- assert:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user