This article will cover the step-by-step process of installing Docker on an Ubuntu Server.
Step 1. Update the apt package index.
sudo apt update
![](https://darryldias.me/wp-content/uploads/apt_update-1024x695.png)
Step 2. Install packages that allow us to use the repository over HTTPS.
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
Code language: JavaScript (javascript)
Step 3. Adding the official Docker GPG keys
sudo mkdir -p /etc/apt/keyrings
![](https://darryldias.me/wp-content/uploads/mkdir_keyrings_directory-1024x661.png)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Code language: JavaScript (javascript)
Step 4. Adding the 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
Code language: PHP (php)
![](https://darryldias.me/wp-content/uploads/added_docker_repository-1024x674.png)
Step 5. Update the apt package index once more, so we have the Docker packages added to the package index.
sudo apt update
![](https://darryldias.me/wp-content/uploads/apt_update-1024x695.png)
Step 6. Install Docker and its components
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin uidmap
Code language: JavaScript (javascript)
![](https://darryldias.me/wp-content/uploads/install_docker_with_dependencies-1024x661.png)
![](https://darryldias.me/wp-content/uploads/docker_install_dependencies-1024x660.jpg)
Step 7. Start Docker.
The command below will start Docker.
sudo systemctl start docker
![](https://darryldias.me/wp-content/uploads/sudo_systemctl_start_docker-1024x667.png)
You can also enable Docker to run at startup. It will be useful if you are using it in production.
sudo systemctl enable docker
![](https://darryldias.me/wp-content/uploads/sudo_systemctl_enable_docker-1024x924.png)
Now that we have Docker installed, we can run the hello-world container.
sudo docker run hello-world
![](https://darryldias.me/wp-content/uploads/docker_run_hello_world-1024x672.jpg)
If the above command runs successfully, we can proceed further and set up Docker to execute rootlessly. It means we don’t need to run sudo before the docker command.
dockerd-rootless-setuptool.sh install
Code language: CSS (css)
![](https://darryldias.me/wp-content/uploads/docker_rootless_setup-1024x587.jpg)
We can now run any docker container rootless, so to test this, let’s rerun the hello-world container.
docker run hello-world
![](https://darryldias.me/wp-content/uploads/docker_run_hello_world_rootless-1024x951.jpg)
We have successfully got Docker up and running.
Leave a comment and share this article if you found it helpful.