Created
April 12, 2023 18:44
-
-
Save shanduur/f1ccd933426de601d5db94d7111c44cc to your computer and use it in GitHub Desktop.
Download Docker CLI when using remote Docker host or Colima
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _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