-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_docker.sh
More file actions
executable file
·116 lines (89 loc) · 3.61 KB
/
install_docker.sh
File metadata and controls
executable file
·116 lines (89 loc) · 3.61 KB
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
#!/bin/bash
# kindmesh Docker Installer
# This script installs Docker and Docker Compose if they are not already installed
echo "=== KindMesh Docker Installer ==="
# Function to detect OS
detect_os() {
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
else
OS=$(uname -s)
VER=$(uname -r)
fi
echo "Detected OS: $OS $VER"
}
# Check if Docker is already installed
if command -v docker &> /dev/null; then
echo "Docker is already installed."
else
echo "Docker is not installed. Installing..."
detect_os
# Install Docker based on OS
if [[ "$OS" == *"Ubuntu"* ]] || [[ "$OS" == *"Debian"* ]]; then
# Update package index
sudo apt-get update
# Install prerequisites
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Set up the stable repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# Update package index again
sudo apt-get update
# Install Docker CE
sudo apt-get install -y docker-ce
# Add current user to docker group
sudo usermod -aG docker $USER
echo "Docker installed successfully. You may need to log out and back in for group changes to take effect."
elif [[ "$OS" == *"CentOS"* ]] || [[ "$OS" == *"Red Hat"* ]]; then
# Install prerequisites
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Add Docker repository
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker CE
sudo yum install -y docker-ce
# Start and enable Docker service
sudo systemctl start docker
sudo systemctl enable docker
# Add current user to docker group
sudo usermod -aG docker $USER
echo "Docker installed successfully. You may need to log out and back in for group changes to take effect."
elif [[ "$OS" == *"Darwin"* ]]; then
echo "For macOS, please install Docker Desktop from https://www.docker.com/products/docker-desktop"
exit 1
else
echo "Unsupported OS: $OS"
echo "Please install Docker manually from https://docs.docker.com/get-docker/"
exit 1
fi
fi
# Check if Docker Compose is already installed
if command -v docker-compose &> /dev/null; then
echo "Docker Compose is already installed."
else
echo "Docker Compose is not installed. Installing..."
# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo "Docker Compose installed successfully."
fi
# Verify installations
echo "Verifying installations..."
docker --version
docker-compose --version
echo ""
echo "=== Docker and Docker Compose installed successfully! ==="
echo ""
echo "You can now run the application using: ./start.sh"
echo ""
# Ask if user wants to start the application now
read -p "Do you want to start the application now? (y/n): " START_APP
if [[ "$START_APP" == "y" ]] || [[ "$START_APP" == "Y" ]]; then
./start.sh
fi
exit 0