-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall-docker.sh
executable file
·43 lines (30 loc) · 1.62 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
#!/bin/bash
# Update the package list
sudo apt update
# Install necessary prerequisites
sudo apt 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 gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Add Docker’s official APT 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
# Update the package list again to include Docker packages
sudo apt update
# Install Docker CE (Community Edition)
sudo apt install -y docker-ce docker-ce-cli containerd.io
# Enable and start Docker service
sudo systemctl enable docker
sudo systemctl start docker
# Add the current user to the docker group to avoid using sudo
sudo usermod -aG docker $USER
# Install Docker Compose
DOCKER_COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
sudo curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# Make Docker Compose executable
sudo chmod +x /usr/local/bin/docker-compose
# Verify installations
docker --version
docker-compose --version
echo "Docker and Docker Compose installation completed successfully."
echo "Please log out and log back in to use Docker without sudo."
echo "Installing Nginx.. for using it as a service on 80"
sudo apt install -y nginx