Configuring Docker through Ansible

Abhishek Arora
2 min readJan 27, 2021

--

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly.

It is a containerization engine that helps us to launch docker containers from the docker images that are available in docker hub. Docker hub is a registry for docker images and there we can download and upload docker images. Docker images of various OS are available and many customized docker images can be made and upload onto Docker hub. Customized docker images can be made either by commit command or the best way to make docker images is through Dockerfile which helps is to customize docker images in a better and faster way.

Ansible is automation tool which helps us to orchestrate any of the IT work. Ansible is agentless i.e. this does not needed to be installed on the managed node and only controller node needs to be having ansible installed.

This task is all about installing docker through ansible and starting docker services in managed node. Also we are downloading httpd docker image which is official apache webserver docker image for launching apache on container

Step 1: Adding docker repository in managed node

Step 2: Installing docker on managed node

Step 3: Starting docker

Step 4: Installing docker SDK for python3

Step 5: Creating container

Now this involves total of 5 steps and this is a small task only but Ansible helps us to automate all of this in one go and we don't need to do anything manually.

We need to run only one command that too from controller node and this will setup docker and run apache container in it. Multiple hosts can be managed simultaneously.

ansible-playbook docker.yml

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response