53 lines
2.0 KiB
Bash
53 lines
2.0 KiB
Bash
if which docker >/dev/null 2>&1; then
|
|
echo "Docker is installed"
|
|
exit 1
|
|
else
|
|
echo "Docker is not installed"
|
|
fi
|
|
|
|
if lsb_release -a 2>/dev/null | grep -q -E "Debian"; then
|
|
echo "Running Debian"
|
|
|
|
sudo apt-get remove docker docker-engine docker.io containerd runc -y
|
|
sudo apt-get update -y
|
|
sudo apt-get install \
|
|
ca-certificates \
|
|
curl \
|
|
gnupg -y
|
|
sudo install -m 0755 -d /etc/apt/keyrings
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
|
echo \
|
|
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
|
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" |
|
|
sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
|
sudo apt-get update -y
|
|
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
|
|
|
elif lsb_release -a 2>/dev/null | grep -q -E "Ubuntu"; then
|
|
echo "Running Ubuntu"
|
|
|
|
sudo apt-get remove docker docker-engine docker.io containerd runc -y
|
|
sudo apt-get update -y
|
|
sudo apt-get install ca-certificates curl gnupg -y
|
|
sudo install -m 0755 -d /etc/apt/keyrings
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
|
echo \
|
|
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
|
|
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" |
|
|
sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
|
sudo apt-get update -y
|
|
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
|
|
|
elif cat /etc/os-release 2>/dev/null | grep -q -i "alpine"; then
|
|
echo "Running Alpine"
|
|
apk add docker docker-compose
|
|
addgroup username docker
|
|
rc-update add docker default
|
|
service docker start
|
|
else
|
|
echo "Unknown distribution"
|
|
exit 1
|
|
fi
|