Skip to content

Instantly share code, notes, and snippets.

@jeremyje
Last active October 31, 2022 01:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyje/5d2b3746f4454ef24aaa723e208b7a50 to your computer and use it in GitHub Desktop.
Save jeremyje/5d2b3746f4454ef24aaa723e208b7a50 to your computer and use it in GitHub Desktop.
Install Docker
#!/bin/bash
# curl https://gist.githubusercontent.com/jeremyje/5d2b3746f4454ef24aaa723e208b7a50/raw/install-docker.sh | bash
# Based on https://docs.docker.com/install/linux/docker-ce/debian/
function InstallForDebian {
sudo apt-get update
sudo apt-get -y remove docker docker-engine docker.io
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
apt-cache madison docker-ce
# https://docs.docker.com/install/linux/linux-postinstall/
sudo groupadd docker
sudo usermod -aG docker $USER
echo Logout to use docker without sudo.
}
# Based on https://docs.docker.com/install/linux/docker-ce/ubuntu/
function InstallForUbuntu {
sudo apt-get update
sudo apt-get -y remove docker docker-engine docker.io
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
apt-cache madison docker-ce
# https://docs.docker.com/install/linux/linux-postinstall/
sudo groupadd docker
sudo usermod -aG docker $USER
echo Logout to use docker without sudo.
}
if [[ "$(lsb_release -si)" == "Debian" ]]; then
InstallForDebian
elif [[ "$(lsb_release -si)" == "Ubuntu" ]]; then
InstallForUbuntu
else
echo "Not supported."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment