Configure Apache Webserver on top of Docker Container with help of Ansible Playbook

Ashish Dwivedi
2 min readMar 24, 2021

OBJECTIVE:

  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 the/var/www/html directory and start the webserver.

PREREQUISIT

  1. Should have 2 linux os yum configured.
  2. Download ansible in master node and configure inventory file Hosts.

Starting with Downloading Docker

Firstly we will configure yum repository for docker in target node for downloading docker and then we will Install docker and will start docker service

We can see docker service is running in our Target Node

Now we will install pip3 command or can say python3 to download docker software development kit (sdk) for integrating docker with ansible

With help of ansible we now download httpd server image from docker hub and will copy content for website in /var/www/html file.

Now we will check in target node that our file index.html is present there or not.

Now we have to expose our container so everybody can see our website

Now if we try to connect with container IP and we see the web page i.e index.html with Output HTTP server on docker which we have written in index.html.

This is final playbook for our entire setup

THANK YOU

HAPPY CODING

--

--