Last active
November 5, 2023 01:08
-
-
Save jasenmichael/aa126356309381d02bdfab79e1052f86 to your computer and use it in GitHub Desktop.
quickly install docker for pop_os (tested on 20.04)
This file contains 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
#! /bin/bash | |
if [[ -z $1 ]] || [[ "$1" != "-r" ]] && [[ "$1" != "--reinstall" ]]; then | |
type docker >/dev/null 2>&1 && echo "Docker already installed, exiting" && exit 0 | |
fi | |
echo "Installing Docker..." | |
sleep 2 | |
# from the docker website - Install Docker Engine on Ubuntu | |
# https://docs.docker.com/engine/install/ubuntu/ | |
sudo apt-get remove docker docker-engine docker.io containerd runc | |
sudo apt-get update | |
sudo apt-get install ca-certificates curl gnupg lsb-release | |
sudo mkdir -p /etc/apt/keyrings > /dev/null 2> /dev/null | |
[[ -f /etc/apt/keyrings/docker.gpg ]] && sudo rm /etc/apt/keyrings/docker.gpg | |
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 chmod a+r /etc/apt/keyrings/docker.gpg | |
sudo apt-get update | |
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin | |
sudo ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose | |
sudo groupadd docker | |
sudo usermod -aG docker $USER | |
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R &> /dev/null | |
sudo chmod g+rwx "$HOME/.docker" -R &> /dev/null | |
# check if docker installed | |
# type docker >/dev/null 2>&1 && echo "Docker installed successfully" || echo "Docker installation failed" && exit 1 | |
# if [ -x "$(command -v docker)" ]; then | |
if [[ $(which docker) && $(docker --version) ]]; then | |
echo "Docker installed successfully" | |
# make the docker group available immediately | |
newgrp docker | |
exit 0 | |
else | |
echo "Docker installation failed" | |
exit 1 | |
fi |
Author
jasenmichael
commented
Nov 25, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment