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


  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.


  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






Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ashish Dwivedi

Ashish Dwivedi

More from Medium

Docker: Shine the Torch

How to Setup a Jenkins to Dockerhub Pipeline with Multi-Arch Images

GitLab — Heroku CI/CD Pipeline in 10 minutes.

Deploy to Heroku