Docker using Ansible

Install and configure Docker and run a web server in the docker container.

In this blog, I will demonstrate how I created an Ansible Playbook that can perform the following operations:

  1. Configure Docker on Centos 8 or RedHat 8
  2. Start and enable Docker services
  3. Pull the httpd server image from the Docker Hub.
  4. Run the Docker container and expose it to the public
  5. Copy the HTML code in /var/www/html directory and start the webserver.

Now we can run the playbook:

$ ansible-playbook docker_conf_httpd_webserver.yml

The playbook ran successfully.

Let’s browse the index.html page in the webserver running on Docker Container.

GitHub: https://github.com/mtabishk/ansible-playbooks/tree/main/docker

That’s all for today! I’ll be back with some new articles very soon, thanks! 🤗

Muhammad Tabish Khanday

LinkedIn: https://www.linkedin.com/in/mtabishk/

--

--