Launching Webserver on the Top of Docker Using Ansible Play-book | Arth | Task-10 |

Gaurav Sharma
3 min readMar 21, 2021

--

Task-Description

🔹 Configure Docker
🔹 Start and enable Docker services
🔹 Pull the httpd server image from the Docker Hub
🔹 Run the docker container and expose it to the public
🔹 Copy the html code in /var/www/html directory and start the web server

Task-Steps

Step-1: Installing docker in linux is not very simple job. First we have to create a repo file for docker with given baseurl

https://download.docker.com/linux/centos/7/x86_64/stable/

Step-2: There are some broken file in this base URL, so we can’t use package module to install docker. We can use command/shell module with “ nobest” option.

Step-3: Now i am going to start the docker service.

Step-4: It is important to install docker SDK before doing any docker operation from ansible.
Step-5: In this step I am going to pull http docker image.

Step-6: Create a directory and copy our code in this directory later we mount this to docker container’s document root.

Step-7: Now launching a docker container.

Here I gave 8080 port to expose the container & also mounted the volume.

Step-8: Now to expose the container for outside world we have to allow 8080 port in the firewall.

Now lets run the play-book

Let’s from the Target node that all tasks are completed or not.

Repository & Software check-

Docker service Status check-

Docker SDK check-

Docker image & Docker Container check-

Inspect Docker container-

Checking the active ports-

Now let check our webserver is working or not.

Yeppie it’s working
Our task is completed.

For code —

!!!Thanks For Reading the Article!!!

--

--