Ansible playbook to configure docker services.

Himanshu Yadav
2 min readJan 23, 2021

Docker is a very essential containerization tool used in almost every service based and software companies. Because it loads operating systems in seconds and thus it can provide a different os for every different tasks used by an software/application etc.

But there is always a problem of doing it in an large scale as there are hundreds of different task for a service and to do it in thousands of systems we need automation tool like Ansible.

Here i am going to show you a demo on how to configure Docker on target node and start a web server container.

First we need IP of our target node :

Now we write ansible-playbook on our master node to configure docker on target node.

we use docker_container module to create container and expose it.

To run this playbook we use command :

ansible-playbook task10.yml

As we can see our playbook run with no errors that means we have started docker and created a container with web-service activated in it.

Now to confirm this we go to our target node and run command :

docker ps

and we can see that a container with httpd service is up 3 seconds ago.

That’s it.

Thank you.

#TASK_10

--

--