-
Notifications
You must be signed in to change notification settings - Fork 172
/
Copy pathdocker.sh
117 lines (107 loc) · 3.3 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# Function to check if Docker is installed
checkDockerInstalled() {
if ! command -v docker &>/dev/null; then
echo "Docker is not installed."
return 1
else
echo "Docker is already installed."
return 0
fi
}
# Function to install Docker
installDocker() {
if ! checkDockerInstalled; then
echo "##############################################################################################################################"
echo "Docker is an open platform for developing, shipping, and running applications."
echo "It enables you to separate your applications from your infrastructure so you can deliver software quickly."
echo ""
echo "Please select your operating system/distribution to install Docker:"
echo "##############################################################################################################################"
echo ""
PS3="Select your OS/Distribution: "
select os_option in \
"Ubuntu 20.04 or 22.04" \
"Debian" \
"CentOS" \
"Fedora" \
"Amazon Linux" \
"OpenSUSE" \
"Quit"
do
case $REPLY in
1) installDockerUbuntu ;;
2) installDockerDebian ;;
3) installDockerCentOS ;;
4) installDockerFedora ;;
5) installDockerAmazonLinux ;;
6) installDockerOpenSUSE ;;
7) exit ;;
*) echo "Invalid selection, please try again..." ;;
esac
done
else
echo "Exiting script as Docker is already installed."
exit 0
fi
}
# Function to install Docker on Ubuntu
installDockerUbuntu() {
clear
echo "Installing Docker on Ubuntu..."
sudo apt update
sudo apt install -y docker.io
echo "Docker installed successfully!"
exit 0
}
# Function to install Docker on Debian
installDockerDebian() {
clear
echo "Installing Docker on Debian..."
sudo apt update
sudo apt install -y docker.io
echo "Docker installed successfully!"
exit 0
}
# Function to install Docker on CentOS
installDockerCentOS() {
clear
echo "Installing Docker on CentOS..."
sudo yum install -y docker
sudo systemctl start docker
sudo systemctl enable docker
echo "Docker installed successfully!"
exit 0
}
# Function to install Docker on Fedora
installDockerFedora() {
clear
echo "Installing Docker on Fedora..."
sudo dnf install -y docker
sudo systemctl start docker
sudo systemctl enable docker
echo "Docker installed successfully!"
exit 0
}
# Function to install Docker on Amazon Linux
installDockerAmazonLinux() {
clear
echo "Installing Docker on Amazon Linux..."
sudo yum install -y docker
sudo systemctl start docker
sudo systemctl enable docker
echo "Docker installed successfully!"
exit 0
}
# Function to install Docker on OpenSUSE
installDockerOpenSUSE() {
clear
echo "Installing Docker on OpenSUSE..."
sudo zypper install -y docker
sudo systemctl start docker
sudo systemctl enable docker
echo "Docker installed successfully!"
exit 0
}
# Call the installDocker function to start the installation process
installDocker