If you are deploying applications, reliable containerization is essential. However, installing Docker from the default Ubuntu repositories often leaves you with outdated versions that lack critical features. This tutorial covers the modern and official way for Ubuntu VPS Docker setup and also includes Docker Compose installation.
This guide ensures your containers run smoothly, which makes it the perfect setup for a high-performance Linux VPS from Perlod Hosting.
Prerequisites for Ubuntu VPS Docker Setup
In this guide, we assume you have an Ubuntu VPS, Ubuntu 22.04, or Ubuntu 24.04. If you are looking for a reliable provider, a high-performance Linux VPS is recommended for production workloads.
Also, you must have SSH access to your server and a user with sudo privileges.
Now, proceed to the following steps to start the Ubuntu VPS Docker setup.
1. Update and Prepare the System
Update your local package index, which prevents conflicts during installation:
Bash
sudoaptupdate&&sudoaptupgrade-y
Install the necessary prerequisite packages that allow apt to use packages over HTTPS with the command below:
Bash
sudoaptinstallca-certificatescurlgnupg-y
2. Add Docker's Official GPG Key
For Ubuntu VPS Docker setup, you must add Docker's official GPG key to a dedicated keyring.
Create the directory for the key with the command below:
Bash
sudoinstall-m0755-d/etc/apt/keyrings
Download the key and give it the proper permission with the commands below:
Once you are done with the GPG key, you can add the Docker repository to your system's source list. To do this, you can use the following command, which automatically detects your Ubuntu version and CPU architecture:
Run the system update again so it sees the new Docker packages:
Bash
sudoaptupdate
4. Install Docker and Docker Compose Plugin
In the past, you might have installed a separate binary for Docker Compose. Today, the standard is the Docker Compose Plugin, which integrates directly into the Docker CLI.
To install Docker and Docker Compose on your Ubuntu VPS, run the command below:
docker-ce-cli: The command-line interface you type into.
containerd.io: The container runtime that manages the container lifecycle.
docker-compose-plugin: Enables the docker compose command.
Note: By default, Docker commands require sudo. This can be a security risk if scripts rely on root. To fix this, add your current user to the Docker group with the command below:
Bash
sudousermod-aGdocker$USER
To apply the changes, you can log out and log in again, or you can activate the group change immediately with this command:
Bash
newgrpdocker
To confirm everything is working correctly, check your Docker and Docker Compose versions:
Bash
docker--version
Bash
Output:Dockerversion29.2.1,builda5c7197
Bash
dockercomposeversion
Bash
Output:DockerComposeversionv5.0.2
Note: The command is docker compose, not docker-compose.
Also, you can run a test container with:
Bash
dockerrunhello-world
If you see a message Hello from Docker, your installation is successful.
Once you are done, restart Docker to apply the changes:
Bash
sudosystemctlrestartdocker
This limits logs to 10MB per file and keeps only the last 3 files.
Conclusion
You have successfully installed the Docker Engine and the Docker Compose plugin using the official repository method. This setup ensures your infrastructure is running the latest stable release with all critical security patches applied. With your environment properly configured and log rotation enabled, your server is now ready for production workloads. Whether you are deploying databases, web apps, or AI models, this foundation ensures your Linux VPS operates efficiently.
We hope you enjoy this guide. Subscribe to our X and Facebook channels to get the latest articles.
The docker-compose command is an outdated and deprecated tool. The docker compose command is the modern and faster standard built directly into Docker.
Because you are trying to run Docker without sudo, but your user doesn't have the necessary permissions. Run sudo usermod -aG docker $USER to resolve it and apply it by logging out and logging back in.
It is recommended to use the apt repository, which installs standard files exactly where they belong on your server. Snap creates complex permission issues and clutters your system with unnecessary virtual drives.
We use cookies to run PerLod and to understand how the site is used. You can accept everything, or open Manage to turn individual categories off. Cookie policy.