-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-docker.sh
executable file
·62 lines (47 loc) · 1.79 KB
/
install-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
#!/bin/sh
# Should run as sudo this script to install docker
ccend=$(tput sgr0)
ccbold=$(tput bold)
ccgreen=$(tput setaf 2)
ccso=$(tput smso)
# Check Ubuntu or CentOS
if [ -n "$(uname -a | grep Ubuntu)" ]; then
# open network to any
# ufw allow out from any to any proto tcp port 80 comment "Repository"
# ufw allow out from any to any proto tcp port 443 comment "Repository"
# Set up the Repository
echo ""
echo "$ccso --> Set up the Repository $ccend"
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg lsb-release software-properties-common
# Add official docker GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Set up the stable docker Repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install docker engine
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
else
# Set up the Repository
echo ""
echo "$ccso --> Set up the Repository $ccend"
sudo yum install -y yum-utils
# Set up the stable docker Repository
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
# Install docker engine
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
fi
echo ""
echo "$ccso --> Start docker $ccend"
sudo systemctl start docker
echo ""
echo "$ccso --> add group & user permission docker $ccend"
# add group & user permission docker
sudo groupadd docker
sudo usermod -aG docker $USER
sudo chmod 666 /var/run/docker.sock
newgrp docker