Install Docker on Linux: A Practical Getting Started Guide

Install Docker on Linux: A Practical Getting Started Guide

#VPS #Tutorial
May 10, 2026

Introduction

Docker makes it easy to run applications and services inside isolated containers on a Linux server. At BoxToPlay, this kind of setup is useful when we want to deploy a tool, a web service, or a test environment quickly on a VPS.

In this tutorial, we will show how to install Docker cleanly on a Debian or Ubuntu based Linux machine, verify that the installation works, and run a first test container.


1. Prerequisites

Before starting, make sure you have:

  • a Debian or Ubuntu based Linux server;
  • SSH access with a user allowed to use sudo;
  • an up to date machine;
  • an active internet connection to download Docker packages.

Example system update output:

sudo apt update && sudo apt upgrade -y

Example output:

Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Get:2 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
...
Reading package lists... Done
Calculating upgrade... Done

2. Remove old Docker packages

Before doing a clean installation, remove any older Docker packages that may already be present. For this tutorial, we use the following official sequence:

sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1)
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Example output:

Reading package lists... Done
Building dependency tree... Done
Package 'docker.io' is not installed, so not removed
...
# Executing docker install script, commit: ...
+ sh -c apt-get -qq update >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get -y -qq install docker-ce docker-ce-cli containerd.io docker-compose-plugin >/dev/null

This method installs Docker Engine together with the modern Docker Compose plugin.


3. Verify the Docker installation

Once the installation is complete, check the available versions:

docker --version
docker compose version

Example output:

Docker version 26.1.0, build ...
Docker Compose version v2.27.0

If both commands return correctly, Docker Engine and Docker Compose are available on the machine.


4. Start and enable the Docker service

On most systems, the service starts automatically. You can still force the service to start and confirm its status:

sudo systemctl enable --now docker
sudo systemctl status docker --no-pager

Example output:

Synchronizing state of docker.service with SysV service script...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service -> /lib/systemd/system/docker.service.
● docker.service - Docker Application Container Engine
     Active: active (running)

This check confirms that Docker will also be started automatically after the next server reboot.


5. Run a first test container

To confirm that Docker is really working, run the hello-world test container:

sudo docker run hello-world

Example output:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
...
Hello from Docker!
This message shows that your installation appears to be working correctly.

If this message appears, your Docker installation is operational.


6. Use Docker without sudo

By default, Docker commands are often run with sudo. If you want to use Docker with your current user, add it to the docker group:

sudo usermod -aG docker $USER
newgrp docker

Depending on your SSH session, a logout and login may still be required to apply the change cleanly.


7. Update Docker later

Once the Docker repository is installed, future updates go through the standard package system:

sudo apt update && sudo apt upgrade -y

Example output:

Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Hit:2 https://download.docker.com/linux/ubuntu noble InRelease
...
Reading package lists... Done

This keeps Docker, its engine, and the Compose plugin up to date on your server.


Conclusion

You now have a clear method to install Docker on Linux, verify the service, test a first container, and prepare your server for future deployments. If you want to perform this installation on a clean machine, you can start your free VPS trial.

Join the Discussion
🍪