forked from DstMlOpsCrypto/MainCrypto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
local_docker_install.sh
74 lines (64 loc) · 2.1 KB
/
local_docker_install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
echo "=== update linux distrib ==="
# Get the operating system value
OS=$(hostnamectl | awk -F': ' '/Operating System/ {print $2}' | tr -d ' ')
# Update the system based on the distribution
case "$OS" in
Ubuntu|Debian)
sudo apt-get update
sudo apt-get upgrade -y
;;
CentOS|Fedora|"RedHatEnterprise")
sudo yum update -y
;;
openSUSE)
sudo zypper update -y
;;
ArchLinux|ManjaroLinux)
sudo pacman -Syu --noconfirm
;;
Alpine)
sudo apk update
sudo apk upgrade
;;
*)
echo "Unsupported distribution: $OS"
exit 1
;;
esac
echo "...done"
echo "=== Install Docker based on the distribution ==="
# Install Docker based on the distribution
case "$OS" in
Ubuntu|Debian)
sudo apt-get install -y ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/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/$OS $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
;;
CentOS|Fedora|"RedHatEnterprise")
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/$OS/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
;;
openSUSE)
sudo zypper install -y docker docker-compose
;;
ArchLinux|ManjaroLinux)
sudo pacman -S --noconfirm docker docker-compose
;;
Alpine)
sudo apk add docker docker-compose
;;
*)
echo "Unsupported distribution: $OS"
exit 1
;;
esac
echo "...done"
echo "=== Add current user to the docker group ==="
# Add the current user to the docker group
sudo usermod -aG docker $USER
echo "...done"