The deploy folder

Streamlining Docker Deployments in a Home Lab with Ansible

Setting up and managing Docker containers across multiple virtual machines can be a massive pain. I have started using a folder named deploy and a script alias ansible-deploy to automate my Docker Compose deployments. This creates a consistent deployment process for a lot of my docker containers.

Folder Structure

I organize all my deployment scripts in a folder called develop and a shell script to run everything. It contains any ansible playbooks and deployment-specific deployment files like .env files or playbook variables.

I also use the file as an entry point to deploying my containers. I use an alias ansible-deploy to call the file

└── deploy/
        └── playbook.yml
        └── .env
├── app files...
├── docker-compose.yml
├── and aliases

ansible-playbook deploy/playbook.yaml

Add the following line to your .bashrc or .zshrc:

alias ansible-deploy='sh ./'

Deploying Your Containers

With everything set up, deploying your Docker containers is easy. Navigate to your project directory and run:


This command will:

  1. Copy the Docker Compose file to the target virtual machines.
  2. Execute the Docker Compose file to set up the containers.

This setup has helped me countless times to deploy my containers and it is by no means a silver bullet for deployment. However, it’s what works for me and hopefully, others looking for a way to start.