Last active
July 27, 2022 12:07
-
-
Save bennof/219c901771b8ab2801ee292cc5a70603 to your computer and use it in GitHub Desktop.
Initialize Debian/Ubuntu Server Script for Docker
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/sh | |
# Install docker on Ubuntu/Debian | |
# (c) 2020-2022 Benjamin 'Benno' Falkner | |
set -e # halt on error | |
cat <<EOF | |
Init deb server | |
(c) 2019-2022 Benjamin 'Benno' Falkner (MIT-License) | |
www.falkner.xyz | |
EOF | |
die() { # error funtction | |
echo "ERROR: $@" | |
exit 1 | |
} | |
#check os | |
test "$(uname)" = "Linux" || die "linux only" | |
#check sudo | |
test "$(id -u)" -eq 0 && SUDO="" || SUDO=sudo | |
# check apt-get | |
apt-get --version > /dev/null || die "APT pkg manager not used/installed" | |
# update | |
$SUDO apt-get update | |
# install curl and firewall | |
$SUDO apt-get -y install \ | |
curl \ | |
ufw \ | |
gnupg \ | |
lsb-release \ | |
ca-certificates | |
$SUDO ufw allow ssh | |
# prepare GPG | |
DIST="$(lsb_release -is | tr '[A-Z]' '[a-z]')" | |
test $DIST = "raspbian" && DIST="debian" | |
$SUDO mkdir -p /etc/apt/keyrings | |
curl -fsSL "https://download.docker.com/linux/$DIST/gpg" | $SUDO gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg | |
# prepare DEB | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$DIST \ | |
$(lsb_release -cs) stable" | $SUDO tee /etc/apt/sources.list.d/docker.list > /dev/null | |
$SUDO apt-get update | |
$SUDO apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment