You can find the main instructions in the Docker documentation (https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository), but see the rest of the tutorial to enable non-sudo docker commands.
For convenience I also will also leave all the commands here.
Prerequisites:
# Add Docker's official GPG key:
$ sudo apt-get update
$ sudo apt-get install 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 "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update
Actual install:
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
After running all the commands above, you should be able to run the following command and see the proper output, however notice that at this point you have to use sudo
:
$ sudo docker run hello-world
Hello from Docker!
...
In order to be able to run docker commands with the current user, run the commands below:
# Add the current user to the Docker group
$ sudo usermod -aG docker $USER
# Apply the group change
$ newgrp docker
# Test
$ docker run hello-world
Hello from Docker!
...
Hope this helps, have fun clickity-clacking.
Leave a Reply