Skip to main content

Command Palette

Search for a command to run...

Configuring docker container using Ansible

Published
2 min read
Configuring docker container using Ansible
S

I am a learner who likes to get behind the new technologies of the world and integrate them for a more efficient workflow. Currently learning AWS, GitOps, Kubernetes, and much more...

Hi there! Today we are going to set up a docker container and then ssh inside to set up a webserver inside the container. I have already discussed docker and containers in previous articles.

ansible.png

Let's Start

Our setup is like this :

  • IP 192.168.43.195 acts as our docker host and the same IP we have put into our Ansible inventory

  • We also have Linux VM which will act as an Ansible controller.

Now we will write the YAML file for our setup. Our YAML file looks like this

Screenshot (1093).png

You can check it here

Ansible container does not have ssh enabled so we can either build ssh enabled image of our own or here I have used a script that will set up ssh inside my container.

Screenshot (1094).png

Now let's run our code.

VirtualBox_Ansible Controller Redhat_13_03_2021_10_51_29.png

VirtualBox_Ansible Controller Redhat_13_03_2021_10_51_45.png

Our playbook ran successfully so let's check if the container is successfully configured with the webserver.

VirtualBox_Ansible CLI 2_13_03_2021_10_49_47.png

Screenshot (1092).png

Everything is working fine. So in this way, we can use ansible to configure and setup custom services inside the docker container.

Thank You for the time and see you again next time ....!!

More from this blog

Written Wisdom

35 posts

I'm a 22-year-old boy with a passion to learn about the DevOps Landscape. I love to explore things and deep dive into how these little pieces of code come together to form such state-of-the-art tools.