Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Added a handy command to dynamically fetch the latest version of compose and install it on Linux. #8735

Closed
wants to merge 8 commits into from

Conversation

wiseaidev
Copy link

Signed-off-by: Harmouch101 [email protected]

What I did
Consider reading the title which is self-explanatory of what I did.

# create the docker plugins directory
mkdir -p ~/.docker/cli-plugins

# download the latest version of the CLI into the plugins directory and rename it to docker-compose with wget.
# the regex "https.*docker-compose-$(uname | awk '{print tolower($0)}')-$(uname -m)$" would match
#  the name of the binary that matches the one intended to be downloaded on the currently running distro.
# ex: on Ubuntu x86, the regex matches: docker-compose-linux-x86_64, and so on...
curl -SL https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep -wo https.*docker-compose-$(uname | awk '{print tolower($0)}')-$(uname -m)$ | wget -i - -O ~/.docker/cli-plugins/docker-compose

# make the CLI executable
chmod +x ~/.docker/cli-plugins/docker-compose

Combining the previous commands would result in the following:

mkdir -p ~/.docker/cli-plugins && curl -SL https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep -wo https.*docker-compose-$(uname | awk '{print tolower($0)}')-$(uname -m)$ | wget -i - -O ~/.docker/cli-plugins/docker-compose && chmod +x ~/.docker/cli-plugins/docker-compose

Related issue

An enhancement rather than a bug fix.
(not mandatory) A picture of a cute animal, if possible in relation to what you did
🐈

…compose and install it on Linux.

Signed-off-by: Harmouch101 <[email protected]>
@page-down
Copy link

page-down commented Oct 5, 2021

Since there is no version number in the release file name, you can just use the latest release link that GitHub officially supports.

Linking to releases - GitHub Docs

To link directly to a download of your latest release asset that was manually uploaded, link to /owner/name/releases/latest/download/asset-name.zip

Note that the latest in GitHub Releases may not be what you want, for example when the latest patch revision of an older major or minor version has been released. It would be better to specify the version explicitly.

curl supports --create-dirs since 2003. And there is no need to use both curl and wget.

The following commands works for Linux and macOS. However it is not recommended to install docker compose blindly.

sudo curl -fSL "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s|tr DL dl)-$(uname -m)" --create-dirs -o /usr/local/libexec/docker/cli-plugins/docker-compose && sudo chmod +x /usr/local/libexec/docker/cli-plugins/docker-compose

Refer to Docker Docs:
https://github.com/docker/docker.github.io/blob/master/compose/install.md

Also, if you hardcode the installation to ~/.docker/cli-plugins without checking the DOCKER_CONFIG environment variable, it may not work.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Signed-off-by: Harmouch101 <[email protected]>
@ndeloof
Copy link
Contributor

ndeloof commented Aug 5, 2024

closing as obsolete

@ndeloof ndeloof closed this Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants