Skip to content

Instantly share code, notes, and snippets.

@MazenElzanaty
Last active June 17, 2020 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MazenElzanaty/778f21272841b4931ba9e289ac74c5fd to your computer and use it in GitHub Desktop.
Save MazenElzanaty/778f21272841b4931ba9e289ac74c5fd to your computer and use it in GitHub Desktop.
Install Docker on Ubuntu
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
RED='\033[0;31m'
NC='\033[0m'
GREEN='\033[0;32m'
echo -e "${RED}Removing old versions...${NC}"
apt purge -qq -y docker docker-engine docker.io containerd runc &> /dev/null
echo -e "${RED}Setting up the repository...${NC}"
apt-get update -qq -y
apt-get install -qq -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
echo -e "${RED}Adding Docker’s official GPG key..${NC}"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
echo -e "${RED}Installing Docker...${NC}"
apt-get update -qq -y
apt-get install docker-ce docker-ce-cli containerd.io -qq -y
echo -e "${RED}Starting Docker Service...${NC}"
systemctl start docker
echo -e "${GREEN}Finished.${NC}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment