Skip to content

Instantly share code, notes, and snippets.

@br4instormer
Last active September 20, 2024 13:50
Show Gist options
  • Save br4instormer/61ce0c7f3ec9a2cf13c18e0f59fdada5 to your computer and use it in GitHub Desktop.
Save br4instormer/61ce0c7f3ec9a2cf13c18e0f59fdada5 to your computer and use it in GitHub Desktop.
Update user-wide docker buildx plugin

Update docker buildx plugin on local user environment

Installation

  1. Place script into ~/bin
  2. Put ~/bin to your local PATH environment if necessary
  3. Set permissions on launch: chmod u+x docker-buildx-update.sh
  4. Install dependencies:
  • wget
  • curl
  • jq

Usage

# will be downloaded last version released on github
docker-buildx-update.sh

# wil be downloaded exact version you pass
docker-buildx-update.sh 0.17.1

Check plugin installed correct

docker system info -f '{{ json .ClientInfo.Plugins }}' | jq '.[] | select(.Name=="buildx")'
#!/usr/bin/env bash
declare version=$1
declare last_version=
json=$(curl -s "https://api.github.com/repos/docker/buildx/releases?per_page=1&page=1")
if [ -n "$version" ]
then
last_version="v${version}"
else
echo "Version not set. Will be downloaded latest one"
last_version=$(echo "$json" | jq -r '.[0].tag_name')
fi;
last_version_url=$(echo "$json" | jq -r ".[0].assets[] | select(.name == \"buildx-$last_version.linux-amd64\") | .browser_download_url" )
if [ ! "$last_version_url" ]
then
echo "Download URL of version $last_version not found"
exit 1
fi
echo "Found version $last_version. Downloading..."
wget -O ~/.docker/cli-plugins/docker-buildx --show-progress --progress bar -q "$last_version_url" \
&& chmod u+x ~/.docker/cli-plugins/docker-buildx \
&& docker buildx version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment