Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install latest version of Docker Compose
#!/bin/bash
# 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
@euclidesmcse

This comment has been minimized.

Copy link

@euclidesmcse euclidesmcse commented Jul 15, 2017

Thank you very much!!!!!! The best !

@fmfpereira

This comment has been minimized.

Copy link

@fmfpereira fmfpereira commented Aug 24, 2017

Simple but effective.

@jkozlick

This comment has been minimized.

Copy link

@jkozlick jkozlick commented Jan 16, 2018

This is very nice, thank you, I was looking for a way to script this!
Since the curl statement in line 4 returns JSON, I used jq to parse it.

COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.tag_name')

@jonashackt

This comment has been minimized.

Copy link

@jonashackt jonashackt commented May 17, 2018

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.

@rjalexa

This comment has been minimized.

Copy link

@rjalexa rjalexa commented Feb 7, 2020

Thank you very much.

@dipuwork99

This comment has been minimized.

Copy link

@dipuwork99 dipuwork99 commented Apr 5, 2020

Found this useful thanks.

@woosungchoi

This comment has been minimized.

Copy link

@woosungchoi woosungchoi commented Aug 31, 2020

Thank you so much!

@steevivo

This comment has been minimized.

Copy link

@steevivo 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

This comment has been minimized.

Copy link

@withakay 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

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