forked from ReyazShaik/devopsscripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdockerinstallubuntu.sh
More file actions
39 lines (29 loc) Β· 1.2 KB
/
dockerinstallubuntu.sh
File metadata and controls
39 lines (29 loc) Β· 1.2 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
#!/bin/bash
set -e
echo "π Updating system..."
sudo apt update
echo "π§Ή Removing old Docker versions (if any)..."
sudo apt remove -y docker docker-engine docker.io containerd runc || true
echo "π¦ Installing prerequisites..."
sudo apt install -y ca-certificates curl gnupg lsb-release
echo "π Adding Docker GPG key..."
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo "β Adding Docker repository..."
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
echo "π₯ Installing Docker Engine..."
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
echo "π Enabling Docker service..."
sudo systemctl enable docker
sudo systemctl start docker
echo "π€ Adding user to docker group..."
sudo usermod -aG docker $USER
echo "β
Docker installation complete!"
echo "βΉοΈ Log out and log back in to use Docker without sudo."