-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.sh
88 lines (72 loc) · 2.33 KB
/
docker.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
#
# Copyright (C) 2023 Dimas Yudha Pratama <[email protected]>
#
#
OS=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
if [ "$EUID" -ne 0 ];
then
echo "You need to run this script with sudo privileges"
sleep 3
clear
exit 1
fi
if [ -z $(getent group docker) ];
then
newgrp docker
fi
usermod -aG docker $USER
if [[ $OS == *"Red Hat"* ]] \
|| [[ $OS == *"CentOS"* ]] \
|| [[ $OS == *"Rocky Linux"* ]] \
|| [[ $OS == *"AlmaLinux"* ]];
then
yum update -y
yum remove docker -y docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce \
docker-ce-cli \
containerd.io
elif [[ $OS == *"Ubuntu"* ]];
then
apt-get update -y
apt-get remove -y docker \
docker-engine \
docker.io \
containerd \
runc
apt-get install -y apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get install -y docker-ce \
docker-ce-cli \
containerd.io
else
echo "The OS that you're using is not supported yet"
sleep 3
clear
exit 1
fi
systemctl enable docker
systemctl start docker
mkdir -p /etc/systemd/system/docker.service.d \
&& echo -e "[Service]\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// -H unix://var/run/docker.sock" \
| tee /etc/systemd/system/docker.service.d/override.conf
systemctl daemon-reload
systemctl restart docker.service