Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install latest version of Docker Compose
#!/bin/bash
## THIS THE THE OLD WAY
## Nowadays, simply follow the Compose installation instructions in the official documentation: https://docs.docker.com/compose/install/
# get latest docker compose released tag
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
# Install docker-compose
sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
chmod +x /usr/local/bin/docker-compose
sh -c "curl -L https://raw.githubusercontent.com/docker/compose/${COMPOSE_VERSION}/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose"
# Output compose version
docker-compose -v
exit 0
@steevivo
Copy link

steevivo commented Oct 25, 2020

I found a much simpler solution today, just use pip install docker-compose (just be sure to have pip package manager installed) and you´ll get the current Compose version installed.

It's not much simpler (be sure to have pip) , this batch is for everyone and it's more simpler for all user

@withakay
Copy link

withakay commented Feb 8, 2021

There is a simpler way to do this.
Github provides a method to link directly to the latest release, see here where it states "To link directly to a download of your latest release asset, link to /owner/name/releases/latest/download/asset-name.zip."

So for docker-compose we just need to use:
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

@dolemoine
Copy link

dolemoine commented Dec 16, 2021

really useful script after struggling for a long time with official doc ! Thx

@hizenburgxb
Copy link

hizenburgxb commented Dec 17, 2021

This s so awesome thank you so very much for the script.

@bumbummen99
Copy link

bumbummen99 commented Jan 27, 2022

If you do not want to use v2 you can use the following:
curl -s https://api.github.com/repos/docker/compose/releases | grep -e 'tag_name\": "1.' | cut -d\" -f4 | head -n 1

@williamhqs
Copy link

williamhqs commented May 31, 2022

@withakay thanks it works! 👍

@deviantony
Copy link
Author

deviantony commented May 31, 2022

This is a 6y old gist :)

There's an easy way to install Compose nowadays in their documentation, I'd recommend using this approach instead: https://docs.docker.com/compose/install/

@mahdiZarepoor
Copy link

mahdiZarepoor commented Jul 15, 2022

Thanks,
That was a piece of cake :)

@withakay
Copy link

withakay commented Jul 15, 2022

Docker Desktop includes docker-compose these days, https://docs.docker.com/compose/install/compose-desktop/

@bumbummen99
Copy link

bumbummen99 commented Jul 16, 2022

Docker Desktop includes docker-compose these days, https://docs.docker.com/compose/install/compose-desktop/

You can even link docker-compose to the compose plugin in the docker folder for compatibility.

ln -s /usr/local/bin/docker-compose /usr/libexec/docker/cli-plugin/docker-compose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment