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:
- Create a secure directory for Docker GPG keys:
sudo install -m 0755 -d /etc/apt/keyrings - 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 - 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
- Check that the Docker background service is active and running:
sudo systemctl status docker
(The output should displayActive: active (running)in green). - 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
| Command | Action |
|---|---|
docker ps | List active running containers |
docker ps -a | List all containers (including stopped ones) |
docker images | List downloaded container images |
docker compose up -d | Launch multi-container app in background |
docker compose down | Stop 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!
