From 5aac2a424073d8c585dd78f23c15a8cce90b8c48 Mon Sep 17 00:00:00 2001 From: Nathaniel Nutter Date: Fri, 27 Jan 2017 16:42:10 -0600 Subject: [PATCH] fix exception when an image has no name This prevents an exception from occurring when an image has no name. While images normally have names it is possible, at least on older versions of Docker, for an image to "lose" its name during a failed `docker rm`. --- lib/ansible/module_utils/docker_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/docker_common.py b/lib/ansible/module_utils/docker_common.py index 2d0f58e1e5..4078ed9af6 100644 --- a/lib/ansible/module_utils/docker_common.py +++ b/lib/ansible/module_utils/docker_common.py @@ -349,7 +349,7 @@ class AnsibleDockerClient(Client): try: for container in self.containers(all=True): self.log("testing container: %s" % (container['Names'])) - if search_name in container['Names']: + if isinstance(container['Names'], list) and search_name in container['Names']: result = container break if container['Id'].startswith(name):