// SSD VPS

How to Install and Configure Docker on a Linux VPS: Complete Guide to Containers

October 04, 2026 · by Alex M.

How to Install and Configure Docker on a Linux VPS: Complete Guide to Containers

Docker has become one of the most widely used tools in the DevOps and web development world. If you have a SSD VPS and want to run isolated, scalable, and easily manageable applications, Docker is the ideal solution. In this guide, you'll learn step by step how to install, configure, and use Docker on a Linux VPS running Ubuntu 22.04.

What Is Docker and Why Use It on a VPS?

Docker is an open-source platform that allows you to package applications together with all their dependencies into a container. Containers are isolated from each other and from the host system, but share the same Linux kernel.

Key advantages:

  • Portability – run the same container on any Linux server
  • Isolation – each application has its own environment with no package conflicts
  • Efficiency – containers consume far fewer resources than virtual machines
  • Scalability – spin up dozens of instances in seconds

To get the most out of Docker, you need a server with fast storage. An NVMe VPS delivers excellent read/write speeds for Docker images and volumes, significantly reducing build and deployment times.

Prerequisites

Before you begin, make sure you have:

  • A VPS with Ubuntu 22.04 LTS (or Debian 11/12)
  • Root access or a user with sudo privileges
  • An active SSH connection
  • At least 1 GB of RAM and 10 GB of disk space

If you don't have a server yet, you can order a high-performance SSD VPS directly from CLIQHOST — with fast provisioning and an intuitive control panel.

Step 1: Update the System

Before any installation, update your package list and existing packages:

sudo apt update && sudo apt upgrade -y

Reboot the server if there are kernel updates:

sudo reboot

Step 2: Install Docker Engine

The recommended method is to use the official Docker repository rather than the package from Ubuntu's default repositories (which may be outdated).

2.1 Install Required Dependencies

sudo apt install -y ca-certificates curl gnupg lsb-release

2.2 Add the Official Docker GPG Key

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
  sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

2.3 Add 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

2.4 Install Docker Engine and Components

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

2.5 Verify the Installation

docker --version
# Docker version 26.x.x, build ...

sudo docker run hello-world

If you see the Hello from Docker! message, the installation was successful.

Step 3: Run Docker Without sudo

By default, Docker requires sudo for every command. To remove this restriction, add your user to the docker group:

sudo usermod -aG docker $USER

Log out and back into your SSH session, then verify:

docker ps
# CONTAINER ID   IMAGE   COMMAND   CREATED   STATUS   PORTS   NAMES

Warning: Users in the docker group effectively have root access to the system through containers. Only add trusted users.

Step 4: Enable Docker to Start Automatically

Make sure the Docker service starts automatically when the VPS reboots:

sudo systemctl enable docker
sudo systemctl enable containerd

Check the status:

sudo systemctl status docker

Step 5: Configure the Docker Daemon

The main Docker configuration file is /etc/docker/daemon.json. Here is a recommended configuration for a production VPS:

sudo nano /etc/docker/daemon.json
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  },
  "storage-driver": "overlay2",
  "live-restore": true
}

Explanations:

  • log-driver + log-opts – limits container log sizes (essential on VPS with limited space)
  • storage-driver: overlay2 – the most performant storage driver for Linux
  • live-restore: true – containers remain running during a Docker daemon restart

Apply the changes:

sudo systemctl restart docker

Step 6: Install Docker Compose

Docker Compose lets you define and run multi-container applications using a simple YAML file. If you installed docker-compose-plugin in step 2, it's already available:

docker compose version
# Docker Compose version v2.x.x

Alternatively, install the standalone version:

sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" \
  -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Step 7: Your First Docker Project – Nginx Application

Let's build a practical example: an Nginx container serving a static HTML page.

7.1 Create the Project Structure

mkdir ~/myapp && cd ~/myapp
mkdir html
echo "<h1>Hello from Docker on CLIQHOST VPS!</h1>" > html/index.html

7.2 Create the docker-compose.yml File

nano docker-compose.yml
version: '3.9'

services:
  web:
    image: nginx:alpine
    container_name: my_nginx
    ports:
      - "80:80"
    volumes:
      - ./html:/usr/share/nginx/html:ro
    restart: unless-stopped

7.3 Start the Application

docker compose up -d

Open your VPS IP address in a browser — you'll see the HTML page.

7.4 Useful Docker Compose Commands

docker compose ps          # container status
docker compose logs -f     # real-time logs
docker compose down        # stop and remove containers
docker compose restart     # restart containers

Step 8: Resource Management – Limit CPU and RAM

On a entry-level VPS, it's important to limit resources per container to prevent one service from consuming the entire server:

services:
  app:
    image: myapp:latest
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 256M
        reservations:
          memory: 128M

Or via direct command:

docker run -d --name myapp \
  --cpus="0.5" \
  --memory="256m" \
  myapp:latest

Step 9: Securing Docker on Your VPS

Container security is a critical topic, especially on servers exposed to the internet.

9.1 Don't Run Containers as Root

In your Dockerfile, specify a non-root user:

FROM node:18-alpine
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser

9.2 Use Custom Docker Networks

Don't leave all containers on the default bridge network:

docker network create --driver bridge myapp_network

In docker-compose.yml:

networks:
  myapp_network:
    driver: bridge

9.3 Restrict Exposed Ports

Bind ports only to the local interface if external access isn't needed:

ports:
  - "127.0.0.1:8080:80"

9.4 Regularly Update Images

docker compose pull    # download new images
docker compose up -d   # restart with new images
docker image prune -f  # clean up old images

For advanced server-level security, our server management service includes security audits and regular updates.

Step 10: Monitoring Docker Containers

10.1 Real-Time Statistics

docker stats

This command displays CPU, memory, network and disk I/O for all active containers.

10.2 Check Logs for a Specific Container

docker logs my_nginx --tail 100 -f

10.3 Enter a Running Container

docker exec -it my_nginx sh

Managing Images and Volumes

Regularly clean up unused resources to free up disk space:

# Remove everything unused (containers, networks, images, volumes)
docker system prune -a --volumes

# List existing volumes
docker volume ls

# Remove a specific volume
docker volume rm volume_name

On a CLIQHOST NVMe VPS, I/O operations with Docker images are significantly faster than on standard SSDs — this makes a real difference in intensive CI/CD pipelines.

Dockerfile – Build Your Own Image

A simple Dockerfile example for a Node.js application:

FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --only=production

COPY . .

EXPOSE 3000

CMD ["node", "server.js"]

Build and run:

docker build -t mynodeapp:1.0 .
docker run -d -p 3000:3000 --name mynodeapp mynodeapp:1.0

Practical Tips for Production

  1. Always use specific tags for images (nginx:1.25, not nginx:latest) — ensures reproducibility
  2. Separate data from the application — store data in Docker volumes, not inside containers
  3. Set up a reverse proxy (Nginx or Traefik) in front of containers for SSL and routing
  4. Enable SSL for any publicly exposed service — get an SSL certificate or use Let's Encrypt
  5. Back up regularly Docker volumes containing important data
  6. Document each service in docker-compose.yml with clear comments

Conclusion

Docker transforms the way you deploy and manage applications on a Linux VPS. With the right configuration, you get an isolated, portable, and easily scalable environment — perfect for personal projects, staging, or production workloads.

If you're just getting started and looking for a VPS suited for Docker, the CLIQHOST team is here to help. Check out our SSD VPS and NVMe VPS offerings — servers optimised for container workloads, with technical support included. Have questions? Contact us and we'll find the right solution together.

SHARE
// what clients say

What Our Clients Say

Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.

★★★★★

"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."

AM
Andrei M.
eCommerce owner · Chișinău
★★★★★

"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."

EV
Elena V.
Web agency · Bălți
★★★★★

"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."

DC
Dmitri C.
SaaS founder · Chișinău