-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_install.sh
35 lines (30 loc) · 1.35 KB
/
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
#!/bin/sh
# Check if Docker is installed
if ! command -v docker &> /dev/null
then
echo "Docker is not installed. Installing Docker..."
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker $USER
echo "Docker installed successfully!"
else
echo "Docker is already installed."
fi
get_latest_release() {
curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4
}
COMPOSE_LATEST_VERSION=$(get_latest_release "docker/compose")
echo "Docker compose plugin latest version: $COMPOSE_LATEST_VERSION"
if ! command -v docker-compose &> /dev/null
then
echo "Docker Compose is not installed. Installing Docker Compose..."
sudo curl -L "https://github.com/docker/compose/releases/download/$COMPOSE_LATEST_VERSION/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!"
else
echo "Docker Compose is already installed."
fi