Skip to content

Instantly share code, notes, and snippets.

@oddstr13
Created November 17, 2020 01:43
Show Gist options
  • Save oddstr13/cf9f21265793406439a4bd53be561b31 to your computer and use it in GitHub Desktop.
Save oddstr13/cf9f21265793406439a4bd53be561b31 to your computer and use it in GitHub Desktop.
Script to quickly install Docker on Debian and Ubuntu based distros
. /etc/os-release
CPU=$(uname -m)
# Order matters, ubuntu is ID_LIKE debian
if [ "${ID}" = "ubuntu" ] || [ "${ID_LIKE}" = "ubuntu" ]; then
DEBUNTU="ubuntu"
RELEASE=$UBUNTU_CODENAME
elif [ "${ID}" = "debian" ] || [ "${ID_LIKE}" = "debian" ]; then
DEBUNTU="debian"
else
echo "Unsupported distro ID=${ID}, ID_LIKE=${ID_LIKE}"
exit 2
fi
if [ -z "${RELEASE}" ]; then
RELEASE=$VERSION_CODENAME
fi
if [ -z "${RELEASE}" ]; then
RELEASE=$(lsb_release -cs)
fi
ARCH=$(dpkg --print-architecture)
# Add repo
echo "# Docker
deb [arch=$ARCH] http://download.docker.com/linux/${DEBUNTU} ${RELEASE} stable
# deb-src [arch=$ARCH] http://download.docker.com/linux/${DEBUNTU} ${RELEASE} stable
" | sudo tee /etc/apt/sources.list.d/docker.list
# Remove old versions
sudo apt-get remove docker docker-engine docker.io containerd runc
# Install docker repo key
wget -qO- https://download.docker.com/linux/debian/gpg | sudo apt-key add -
# Install docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment