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.
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
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.
Now let's run our code.
Our playbook ran successfully so let's check if the container is successfully configured with the webserver.
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 ....!!