Skip to content

Instantly share code, notes, and snippets.

@shanduur
Created April 12, 2023 18:44
Show Gist options
  • Select an option

  • Save shanduur/f1ccd933426de601d5db94d7111c44cc to your computer and use it in GitHub Desktop.

Select an option

Save shanduur/f1ccd933426de601d5db94d7111c44cc to your computer and use it in GitHub Desktop.
Download Docker CLI when using remote Docker host or Colima
_get_docker() {
OS="$(uname -s)"
if [[ "${OS}" == "Darwin" ]]; then
OS="mac"
fi
# if arm64 then assume aaarch64
ARCH="$(uname -m)"
if [[ "${ARCH}" == "arm64" ]]; then
ARCH="aarch64"
fi
# get latest version from docker/cli tag that is not a release candidate
VERSION="$(curl -s https://api.github.com/repos/docker/cli/tags | jq -r '.[] | select(.name | test("beta") | not) | .name' | head -n 1)"
# remove v prefix
VERSION="${VERSION#v}"
# download docker cli
curl -L "https://download.docker.com/${OS}/static/stable/${ARCH}/docker-${VERSION}.tgz" | tar -xz -C "$1"
# move docker cli to path
mv "$1/docker/docker" "$1/docker-cli"
rm -rf "$1/docker"
mv "$1/docker-cli" "$1/docker"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment