kurtcms.org

Thinking. Writing. Philosophising.

Email Github LinkedIn

Automation: Docker Compose

Posted on December 13, 2021 — 1 Minute Read

While Ansible and Terraform are incredibly handy in server and cloud automation that provision Infrastructure as Code (IaC). For simpler tasks, a good old Bash script is just as useful. Case in point – automating the process of installing Docker and Docker Compose on a Ubuntu Linux Operating System (OS) with a Bash script, for deploying containerised app, takes merely a few lines.

The rest of the code is shared on Github for reference and further development. With the code packaged as a standalone script, deployment is as simple as:

  1. Download a copy of the script;
  2. Provide the script with execute permission; and
  3. Run the script.

Git Clone

Download a copy of the script with git clone.

$ git clone https://github.com/kurtcms/docker-compose /app/docker-compose/

Permission

Provide the script with execute permission.

$ chmod +x /app/docker-compose/docker-compose.sh

Run

Run the script manually or as part of an automation workflow.

$ /app/docker-compose/docker-compose.sh

And have Docker Compose installed.

Thoughts

This is just one example of using a simple Bash script to execute and automate commands. There are plenty of other fascinating tasks that can be done and with Bash. Explore and be amazed.