Ansible on Docker

I prefer running Codes on a container than a virtual machine and I use docker container to run the ansible playbooks.

Today’s blog is about setting up a docker container environment for ansible.

Pull Image:-

I use python image to setup the Ansible container.

docker pull python

Create Docker Container :-

Docker run -d -i --name cucm python bash

Verify the Running Docker:-

docker ps

Use VSCode to connect the container:-

Use Green Connect symbol on the left side corner.

Choose attach to the running container option

Select the Container.

Upload files to Container.

To upload files to container folder, use below command from CMD. Define the path according to your requirement. The below command is to copy complete files from a folder to a container root folder.

docker cp C:\Users\nithine\Desktop\code\. <<container-ID>:/root/

Download a file from Container.

Right click on the file and choose download option to download the file to your PC.

Install Ansible on Container.

using pip3 install ansible.

 pip3 install ansible 

You can start using your playbooks on the container which we setup.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s