░█░█░█▀█░█▀▄░█▀▄░▀█▀░█▀▀░█▀█░█▀█░█▀█░█▀▄░▀█▀░█░█░░░░█▀▀░█▀█░█▄█ ░█▀█░█▀█░█▀▄░█▀▄░░█░░▀▀█░█░█░█░█░█▀█░█▀▄░░█░░█▀█░░░░█░░░█░█░█░█ ░▀░▀░▀░▀░▀░▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀░▀░▀░▀░░▀░░▀░▀░▀░░▀▀▀░▀▀▀░▀░▀

Installing Docker

Download and run the convenience script from Docker:

1curl -fsSL https://get.docker.com -o get-docker.sh
2sudo sh get-docker.sh

This script auto-detects your distro, adds Docker’s official repository, and installs docker-ce, docker-ce-cli, containerd.io, as well as compose and buildx plugins. It works on Ubuntu, Debian, Fedora, and most common distros. Always review scripts before piping them into sh.

Verify the Daemon Is Running

1sudo systemctl status docker

You should see active (running). If not:

1sudo systemctl start docker
2sudo systemctl enable docker

enable ensures Docker starts automatically on boot.

Run Docker Without Sudo

1sudo groupadd docker
2sudo usermod -aG docker $USER
3newgrp docker

groupadd docker creates the docker group if it doesn’t already exist (the install script may have already done this, the command is harmless if the group is already there).

usermod -aG appends your user to it without affecting your other groups.

newgrp activates the membership in your current shell. Alternatively, log out and back in.

Security note: Members of the docker group have root-equivalent access on the host, since they can mount any filesystem into a container. Only add trusted users.

Verify It Works

1docker run hello-world
2docker compose version

Both should work without sudo. If docker run gives a permission error, try logging out and back in so the group membership takes full effect.

Remove the install script once you’re done:

1rm get-docker.sh

#Bash #Docker