Zuletzt aktiv 1747730508

Änderung c9f2e4a83e0e25c16cb7108c510f1528c0f9c8d6

install_docker.sh Orginalformat
1#!/usr/bin/env bash
2set -euo pipefail
3
4export DEBIAN_FRONTEND=noninteractive
5
6# -------- helpers --------
7retry() {
8 local cmd="$1"
9 local what="$2"
10 until eval "$cmd"; do
11 echo "$what failed, retrying in 5 seconds…"
12 sleep 5
13 done
14}
15
16# -------- remove any old Docker bits --------
17retry "apt-get remove -y docker.io docker-doc docker-compose containerd runc || true" "apt-get remove"
18
19# -------- base package refresh --------
20retry "apt-get update -y" "apt-get update"
21retry "apt-get install -y apt-transport-https ca-certificates curl software-properties-common" \
22 "install prerequisites"
23
24# -------- add Docker repo & key --------
25if [[ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ]]; then
26 curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
27 | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
28fi
29
30codename="$(lsb_release -cs)"
31echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
32https://download.docker.com/linux/ubuntu ${codename} stable" \
33 > /etc/apt/sources.list.d/docker.list
34
35retry "apt-get update -y" "apt-get update (Docker repo)"
36
37# -------- install Docker engine & plugins --------
38retry "apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin" \
39 "install Docker"
40
41# -------- enable & start --------
42systemctl enable --now docker
43
44# -------- quick validation --------
45docker run --rm hello-world
46echo "✅ Docker installed and working."
47