From 6bbec3c95f1df674497e7bf3646d7abeb4693c16 Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Sun, 11 Jun 2023 21:05:43 +0200 Subject: [PATCH] install docker script --- resources/scripts/install-docker.sh | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 resources/scripts/install-docker.sh diff --git a/resources/scripts/install-docker.sh b/resources/scripts/install-docker.sh new file mode 100644 index 0000000..69b7f0b --- /dev/null +++ b/resources/scripts/install-docker.sh @@ -0,0 +1,52 @@ +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