-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerup.txt
More file actions
32 lines (25 loc) · 1.47 KB
/
dockerup.txt
File metadata and controls
32 lines (25 loc) · 1.47 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
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove -y $pkg; done
# Add Docker's official GPG key:
sudo apt-get update -y
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Test if Docker is running correctly without downloading additional images
sudo docker info || { echo "Docker is not running properly"; exit 1; }
echo "Docker is installed and running properly"
# Create the docker group if it doesn't exist
sudo groupadd -f docker
# Add current user to the docker group
sudo usermod -aG docker $USER
# Apply new group settings (note: this will only take effect after logout/login)
echo "User added to docker group. Log out and log back in (or run 'newgrp docker') for changes to take effect."
echo "After logging out and back in, you should be able to run Docker without sudo:"
echo "docker run hello-world"