I recently put together a lightweight Ansible lab using Docker — and it’s been a super clean way to test playbooks without spinning up virtual machines or using the cloud.

Whether you're learning Ansible or just want a disposable playground, this setup gives you:


⚙️ What's Inside?

  • 🐧 Three Ubuntu containers (managed nodes)
  • 🔐 SSH enabled (user: root, password: root)
  • 🐍 Python pre-installed for Ansible modules
  • 🌐 Docker network named ansible
  • 🎯 Port forwarding so you can SSH from your local machine

🚀 Why I Built This

I wanted a quick, minimal lab that would let me focus on learning Ansible without spending time managing VMs or cloud resources. With Docker Compose, I just run:

docker-compose up --build -d

…and I’m ready to automate.


🧪 Try It Out

Here’s what you need to do:

  1. Clone the repo
git clone https://github.com/sheharyar566/ansible-docker-lab.git
   cd ansible-docker-lab
  1. Start the lab
docker-compose up --build -d
  1. SSH into a node
ssh root@localhost -p 2221
  1. Create an inventory file for Ansible and run:
ansible -i inventory.ini all -m ping

🔗 Repo

👉 GitHub – Ansible Docker Lab


🌟 Found This Useful?

If this lab helped you out or saved you time, feel free to give the repo a star on GitHub! It’s a great way to show your support and help others find it too.

Happy automating! ⚙️