---
title: "Install Docker Compose from Binary"
date: 2023-07-20T15:56:11.000Z
author: Z.SHINCHVEN
tags: [docker-compose]
canonical: https://atlassc.net/2023/07/21/install-docker-compose-from-binary
---
This following script can be used on a Ubuntu server to install the latest version of Docker Compose from the binary. 

- It will check if the required packages are installed and install them if they are missing. 
- It will also check if the binary was downloaded successfully and if it was, it will make it executable. 
- Finally, it will print the Docker Compose version to verify the installation.

```bash
#!/bin/bash

# Check if jq and curl are installed, list the missing packages
missing_packages=""
if ! command -v jq &> /dev/null; then
    missing_packages+="jq "
fi

if ! command -v curl &> /dev/null; then
    missing_packages+="curl "
fi

# If any packages are missing, update the package list and install missing packages
if [ ! -z "$missing_packages" ]; then
    echo "Installing missing packages: $missing_packages"
    apt update && apt install -y $missing_packages
fi

# Fetch latest release from GitHub API
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/docker/compose/releases/latest" | jq -r .tag_name)
echo "Latest release: $LATEST_RELEASE"

# Download the Docker Compose binary using your specific OS and architecture
curl -L "https://github.com/docker/compose/releases/download/${LATEST_RELEASE}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

# Check if the binary was downloaded successfully
if [ $? -ne 0 ]; then
    echo "Failed to download Docker Compose binary"
    exit 1
fi

# Make the Docker Compose binary executable
chmod +x /usr/local/bin/docker-compose

# Print the Docker Compose version to verify the installation
docker-compose --version

```
