Article Background
Back to Knowledgebase

How to Install Docker and Docker Compose on an Ubuntu VPS

VPS
Cubes Support
July 20, 2026

Docker is the industry-standard containerization platform that allows developers to package applications, microservices, and game servers into lightweight, isolated containers.

Running Docker on a Cubes Hosting Ubuntu VPS gives you a clean, repeatable environment for deploying databases, web applications, Pterodactyl panels, and custom bots without worrying about dependency conflicts.

This step-by-step guide will walk you through installing the official Docker Engine and Docker Compose V2 on Ubuntu 22.04 or 24.04 LTS.


Step 1: Update Packages & Install Prerequisites

Connect to your VPS via SSH as root or a user with sudo privileges:

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

Step 2: Add Docker's Official GPG Key & APT Repository

To ensure you receive the latest stable security updates and releases directly from Docker:

  1. Create a secure directory for Docker GPG keys:
    sudo install -m 0755 -d /etc/apt/keyrings
    
  2. Download Docker's official GPG key:
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    sudo chmod a+r /etc/apt/keyrings/docker.gpg
    
  3. Add the Docker APT repository to your system sources:
    echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
      $(. /etc/os-release && echo "$UBUNTU_CODENAME") stable" | \
      sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    

Step 3: Install Docker Engine & Docker Compose

Now update your package index and install Docker Engine, the CLI, and the Docker Compose V2 plugin:

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

Step 4: Verify Docker Service Status & Version

  1. Check that the Docker background service is active and running:
    sudo systemctl status docker
    

    (The output should display Active: active (running) in green).
  2. Verify that Docker Compose V2 is installed:
    docker compose version
    

    (Example output: Docker Compose version v2.24.x).

Step 5: Test Docker with a Test Container

Run the official test container to verify that Docker can fetch images from Docker Hub and execute containers:

sudo docker run hello-world

If successful, Docker will download the test image and output:

Hello from Docker!
This message shows that your installation appears to be working correctly.

Optional: Run Docker Commands Without sudo

By default, executing Docker commands requires typing sudo. If you want your non-root system user to run Docker commands directly:

sudo usermod -aG docker $USER
newgrp docker

👉 Check out our complete guide on How to Run Docker Commands Without Sudo for detailed user management steps.


Useful Docker CLI Commands Cheat Sheet

CommandAction
docker psList active running containers
docker ps -aList all containers (including stopped ones)
docker imagesList downloaded container images
docker compose up -dLaunch multi-container app in background
docker compose downStop and remove multi-container app
docker logs <container_name>View live logs for a container

Conclusion

Docker Engine and Docker Compose V2 are now fully installed on your Cubes Hosting Ubuntu VPS! You are ready to deploy containerized web apps, databases, and game server nodes with total environment isolation!

Special Offer

Ready to Start Your Server?

Get 10% OFF your first month on any server with promo code CUBES10 at checkout!

24/7 Assistance

Need Help With Your Server?

Already a Cubes Hosting customer and couldn't find your answer? Our dedicated support team is available 24/7.