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.
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:-
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.