Check the docker container status

I have a pretty straightforward script where i copy some configuration files from ansible host to a linux machine and then start a docker container mounting those config files.
My Docker container are immutable, so i don’t mind recreating them often. In fact, i would like to recreate them in case config changes or they are found stopped. For this i really need a nice way to check status of a container. So the first question - How can i check the status of a Docker container in Ansible ? (i would like to avoid the solution where we match for container name and status in the output of Docker ps command)

Currently, my simple idempotent script is: