After setting up the VM and adding packages as curl sudo ssh …
curl -fsSL <https://download.docker.com/linux/debian/gpg> | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Why? Adds Docker’s GPG key to your system, which ensures that the packages you're going to download are from a trusted source (Docker).
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] [<https://download.docker.com/linux/debian>](<https://download.docker.com/linux/debian>) $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Why? Adds Docker’s official repository to your system so you can install Docker using apt
commands.
sudo apt install docker-ce docker-ce-cli [containerd.io](<http://containerd.io/>) -y
Why? Installs Docker’s core components: Docker Engine (docker-ce
), Docker CLI (docker-ce-cli
), and the containerd runtime (containerd.io
).
sudo usermod -aG docker $USER
Why? Normally, you need sudo
to run Docker commands. Adding your user to the Docker group allows you to run Docker commands without sudo
sudo systemctl enable docker