"Cannot start container" when running docker task

I occasionally get the following error in some of my docker tasks, which stops ansible-playbook dead:

“changed”: true, “failed”: true, “msg”: “Docker API Error: Cannot start container 1117bfd50795c71278d75e6f97ef1a1d67b5758658b57a5803ceffb28dea8565: Error getting container 1117bfd50795c71278d75e6f97ef1a1d67b5758658b57a5803ceffb28dea8565 from driver devicemapper: Error mounting ‘/dev/mapper/docker-202:1-153569-1117bfd50795c71278d75e6f97ef1a1d67b5758658b57a5803ceffb28dea8565’ on ‘/var/lib/docker/devicemapper/mnt/1117bfd50795c71278d75e6f97ef1a1d67b5758658b57a5803ceffb28dea8565’: no such file or directory”

More often than not, if I re-run the same ansible-playbook command again it works fine. Has anyone encountered this, and if so did you manage to resolve it?

Thanks,
Guy

I occasionally get the following error in some of my docker tasks, which
stops ansible-playbook dead:

"changed": true, "failed": true, "msg": "Docker API Error: Cannot start
container 1117bfd50795c71278d75e6f97ef1a1d67b5758658b57a5803ceffb28dea8565:
Error getting container
1117bfd50795c71278d75e6f97ef1a1d67b5758658b57a5803ceffb28dea8565 from driver
devicemapper: Error mounting
'/dev/mapper/docker-202:1-153569-1117bfd50795c71278d75e6f97ef1a1d67b5758658b57a5803ceffb28dea8565'
on
'/var/lib/docker/devicemapper/mnt/1117bfd50795c71278d75e6f97ef1a1d67b5758658b57a5803ceffb28dea8565':
no such file or directory"

More often than not, if I re-run the same ansible-playbook command again it
works fine. Has anyone encountered this, and if so did you manage to resolve
it?

If you're getting a transient Docker API error, that's almost
certainly not an issue with Ansible; it's likely that you're running
Docker frequently enough to trigger some transient error. My guess is
that you'd be running into that problem if you ran Docker repeatedly
on the command line.

In fact, this issue looks a lot like what you're seeing:

https://github.com/docker/docker/issues/4036

Looks like a Docker race condition.

--g

Ok, thanks Greg. I’ll follow up your lead.