Deploy Web Server on Docker through Ansible

Aditya Raj
2 min readSep 9, 2020

Task Description :-

Write an Ansible PlayBook that does the following operations in the managed nodes:

1. Configure Docker

2. Start and enable Docker services

3. Pull the httpd server image from the Docker Hub

4. Run the httpd container and expose it to the public

5. Copy the html code in /var/www/html directory and start the Web server

Step 1 : Configure Docker on Managed Node.

In this step we will create a playbook which will configure docker on managed node.

For installing the docker software first we need to configure and then we will use command module to install docker software.

After installing the docker software we start docker service on managed node.

Step 2 : Pull httpd image from Docker Hub and launch httpd container.

In this step we will write the task which will pull httpd server image from the docker hub and also launch the container from that image. After launching the container it will also expose it.

Step 3 : In this step we will run the playbook.

Now we can check the managed node.

Thank You !!

--

--

Aditya Raj

I'm passionate learner diving into the concepts of computing 💻