Ansible wait_for with docker_container
When using Ansible’sdocker_container
to manage containers, we’ve seen people use wait_for
ensure the container is started.
This requires that the container exposes a port and typically on the host network. Then the IP and the exposed/published port can be used to verify the container (or the service inside) is running.
What if there is no port, or no host binding?
If there is nothing to expose from the container (e.g. think of a queue worker), the following can be done:
If however you expose a port, but not on the host, then the following will help to grab the IP of the container and to be able to verify operation:
FIN
That’s all, thanks for reading.