Skip to content

Instantly share code, notes, and snippets.

@cseelye
Last active August 1, 2023 17:56
Show Gist options
  • Save cseelye/7fd9fe4ad36308cdc79b515f8e26fb06 to your computer and use it in GitHub Desktop.
Save cseelye/7fd9fe4ad36308cdc79b515f8e26fb06 to your computer and use it in GitHub Desktop.
Install the latest docker on Ubuntu with multi architecture support
#!/usr/bin/env bash
set -euETo pipefail
shopt -s inherit_errexit
set -x
sudo rm -f /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get install --yes --no-install-recommends \
ca-certificates \
curl \
gnupg \
lsb-release \
qemu \
qemu-user-static
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install --yes --no-install-recommends \
docker-ce \
docker-ce-cli \
containerd.io \
docker-compose-plugin
sudo usermod -aG docker ${USER}
# Find the latest buildx plugin and download
mach=$(uname -m)
if [[ ${mach} == "x86_64" ]]; then
mach="amd64"
elif [[ ${mach} == "aarch64" ]]; then
mach="arm64"
fi
mkdir -p $HOME/.docker/cli-plugins/
latest=$(curl -fsSL https://api.github.com/repos/docker/buildx/releases/latest | jq -r '.assets[] | select(.name | endswith("linux-'${mach}'")) | .browser_download_url')
curl -fsSL ${latest} -o $HOME/.docker/cli-plugins/docker-buildx
chmod +x $HOME/.docker/cli-plugins/docker-buildx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment