Using Ansible to Install Docker

🔰Write an Ansible PlayBook that does the following operations in the managed nodes:
🔹 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

This was the task provided to me by Vimal Sir, in order to get our basic concepts for ansible playbook, better and easy to use in future

So, I did the given task in the following Steps:-

Step 1:- Checking the hosts availability.

Using the command ansible all — list-hosts to check the available hosts.

Step 2:- Creating an Ansible Playbook with the given commands

I wrote an Ansible playbook to first create Docker repo, then installed Docker using the command, to ensure installation. Then I created Docker container of image httpd and connected the ports between the servers.

Step 3: Executing the Ansible Playbook

So, this was the output of executing the playbook. It was successfully executed, and to check the execution, we open the webpage exposed to the docker container.

Step 4:- Checking the Output

This successfully states that We created a Docker container just by using the commands given in the ansible playbook

This shows the power of the declarative language used by Ansible





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

Recommended from Medium

Deploy ASP.NET Core Application on AKS with Helm through Azure DevOps.

10 Best Voice Changers for Discord in 2022 [Windows, Mac, Android, & iOS]

Single Source of Truth…and Why it Matters

Why we built Clinic 🏥 w/ Botox 💉— a reverse proxy management platform

Frontend — a trap of low entry threshold — part II

Python Operators

Laravel 9 Image Upload Example

Laravel 9 Image Upload Example

Using AWS Lambda environment variables from local .env file (Python 3.7)

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
Arya Dhorajiya

Arya Dhorajiya

More from Medium


Dimensions of Counterfeiting.

Image Re-sizing and “Open with Code” in the Nautilus Context Menu

How to Make an Intruder Alarm with PIR/Motion Sensor and ESP32