Mar 05, 2025
Ariffud M.
7min Read
Docker is a powerful platform to automate application deployments using lightweight, portable containers. Setting up Docker on a Linux server can significantly enhance your development workflow.
In this guide, you’ll learn how to install Docker on Ubuntu using Hostinger’s VPS template and manually. By the end of this article, you’ll have a fully functional Docker setup ready for your projects.
Download free docker cheat sheet
Before following our Docker installation guide, make sure your Ubuntu system meets the following prerequisites:
Need a refresher on what Docker is? Check out our article to understand how Docker works and what its components are.
Using Hostinger’s preconfigured template is the easiest way to set up Docker on your Ubuntu VPS. Available for both VPS and Docker hosting plans, this method saves time and ensures Docker is installed correctly with all necessary components.
Follow these steps to install Docker with Hostinger’s VPS template:


That’s it! You have installed Docker on your VPS and are ready to deploy applications.

For those who prefer a hands-on approach, this section will guide you through manually installing Docker on an Ubuntu 24.04 distribution.
To begin installing Docker, verify that your system is up to date and has all the required packages installed. Follow these steps:
ssh username@your_server_ip
sudo apt update
sudo apt upgrade
sudo apt install apt-transport-https ca-certificates curl software-properties-common
To ensure the authenticity and security of the Docker packages, you need to add Docker’s official GPG key and set up the Docker repository. Here’s the guide:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
With the necessary repositories set up, you can now proceed to install Docker. Here are the steps to do so:
apt-cache policy docker-ce
docker-ce:
Installed: (none)
Candidate: 5:26.1.3-1~ubuntu.24.04~noble
Version table:
5:26.1.3-1~ubuntu.24.04~noble 500
500 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages
5:26.1.2-1~ubuntu.24.04~noble 500
500 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages
5:26.1.1-1~ubuntu.24.04~noble 500
500 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages
…
sudo apt install docker-ce docker-ce-cli containerd.io
sudo systemctl enable docker
After installing Docker, it’s important to verify that the installation was successful and that Docker is running correctly. Here are the instructions:
docker --version
Docker version 26.1.3, build b72abbb
sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled)
Active: active (running) since Wed 2024-05-22 06:12:32 UTC; 39s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 3717 (dockerd)
Tasks: 9
Memory: 29.4M (peak: 29.8M)
CPU: 334ms
CGroup: /system.slice/docker.service
└─3717 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
By default, Docker only allows you to run its commands as a root user with sudo privileges, which can be inconvenient and potentially less secure. If you attempt to run Docker commands as a non-root user, you might see an error like this:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
However, running Docker without sudo is more advisable because it’s quicker and simpler. Follow this guide:
sudo groupadd docker
sudo usermod -aG docker new_user
sudo usermod -aG docker new_user
su - new_user
groups
new_user users docker
docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:266b191e926f65542fa8daaec01a192c4d292bff79426f47300a046e1bc576fd
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
Congratulations! You’ve successfully set up Docker manually on an Ubuntu VPS using commands.
Installing Docker can sometimes come with challenges. Here are some common issues and actionable tips to resolve them.
Docker Daemon Not Running
If you receive an error message indicating that the Docker daemon is not running, it likely means the service is not active. To resolve this, start the Docker service using the command:
sudo systemctl start docker
You can verify the Docker daemon’s status by running:
sudo systemctl status docker
Cannot Connect to the Docker Daemon
If you encounter the “Cannot connect to the Docker daemon at unix:///var/run/docker.sock” error, it usually means the Docker service is not running or there are permission issues.
First, make sure the Docker service is running with:
sudo systemctl start docker
Then, verify that your user is part of the Docker group by running the following:
groups
Installation Issues from Repositories
Problems when adding the Docker APT repository or during package installation can arise from incorrect repository setup. Make sure you have added the official repository and updated your package list by running:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
Running Containers Not Responding
If running containers are not responding or behaving unexpectedly, check the container logs to diagnose the issue. Use the command:
docker logs container_id
Alternatively, Hostinger VPS users can use the Kodee AI Assistant to check their container logs. Simply ask, “Can you check the logs of the [container_name] container?” like the following example:

If necessary, restart the container by executing:
docker restart container_id
Firewall and Network Configuration
Sometimes, Docker might face issues due to firewall settings or network configurations blocking necessary ports. Ensure that your firewall allows traffic on Docker’s default ports. You can check your firewall rules and add necessary exceptions if required.
For example, if you’re using Uncomplicated Firewall (UFW), you can allow Docker traffic with:
sudo ufw allow 2375/tcp
sudo ufw allow 2376/tcp
sudo ufw allow 2377/tcp
sudo ufw allow 7946/tcp
sudo ufw allow 7946/udp
sudo ufw allow 4789/udp
Additionally, verify your network settings to ensure Docker can communicate with external servers to download images and perform other tasks.
After installing Docker, new users should become familiar with several necessary commands and tasks. This section will cover some Docker post-installation configurations and tips.
Basic Docker Commands
Getting started with Docker involves learning a few essential commands. Here are some commands that every new user should know:
docker images
docker search image_name
docker pull image_name
Furthermore, check our Docker cheat sheet guide to learn all the most essential commands and their purposes.
Running and Managing Docker Containers
Running and managing containers is a core part of working with Docker. Here’s a guide to perform these tasks:
docker run -d --name container_name image_name
docker start container_id_or_name
docker stop container_id_or_name
docker ps
Working with Docker Images
Docker images are the basis for containers. Here’s how you can work with images:
docker build -t image_name .
docker tag source_image_name target_image_name:tag
docker login
docker tag image_name dockerhub_username/image_name:tag
docker push dockerhub_username/image_name:tag
Deleting Unused Docker Components
To keep your environment clean and efficient, you need to remove unused Docker components regularly. Here’s how to do so:
docker image prune
docker container prune
docker volume prune
docker network prune
Using Docker Compose
Docker Compose is a powerful tool for managing multi-container applications. Here’s a basic command to get it started:
docker-compose up -d
This starts services defined in the docker-compose.yml file in detached mode.
Did you know that you can run WordPress as a Docker container? Learn how in our article.
In this Docker tutorial, you’ve learned how to install Docker on an Ubuntu system, both using Hostinger’s VPS template and a manual approach. You’ve also understood the importance of verifying the installation and troubleshooting common issues.
Furthermore, it’s advisable to practice essential Docker commands, manage containers and images, and clean up unused components. By following these instructions, you can effectively set up and manage Docker for deploying your applications.
This section answers the most common questions about installing Docker on Ubuntu.
After installing Docker on Ubuntu, it’s recommended to configure Docker to run without sudo for convenience. Additionally, make sure your firewall settings allow Docker traffic and adjust any necessary network configurations for smooth access to external resources.
Currently, Docker supports installation on Ubuntu 20.04, 22.04, and 24.04. It’s advisable to use a long-term support version for stability. Additionally, always check Docker’s official documentation for the latest compatibility information.
To verify if Docker is successfully installed on Ubuntu, run docker –version to check the installed version and sudo systemctl status docker to confirm the Docker service is active and running.
Yes, you can run Docker without root privileges by adding your user to the docker group. Run the command sudo usermod -aG docker your_username as root and then switch to the user with su – your_username.
All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.