May 13, 2024

16 min read

Getting Started With Docker On a VPS (Simple 2024 Tutorial)

Written by

Abdelhadi Dyouri
Getting started with Docker on a VPS is pretty straightforward, and once you're set up via this Docker tutorial, it's like you've "leveled up" in DevOps. In this article, I will go through how Docker can benefit your VPS, how to install it, and how to use it.

Why Get Started with Docker on a VPS?

Docker is a platform for designing, building, and launching "containers," which are isolated environments containing all the software and configuration files necessary to run a service or application. Running Docker on your virtual server gives you more stability, more flexibility, and a lot more ways to recover quickly if (or when) you mess things up. docker vps Installing Docker on your VPS brings significant benefits:
  • You can develop locally using a specific environment.
  • You can ensure that local development environment is replicated exactly when you're ready to deploy code, ensuring 100% compatibility.
  • Build Dockerfiles/Docker images to make your site/app portable to multiple VPSs for redundancy or fail-over.
  • Host multiple applications on a single VPS without them interacting—or conflict—with one another. For example, run two Wordpress installations with separate Apache/Nginx web servers and separate MySQL databases.
  • One container can crash without affecting other containers or the health of your VPS.
  • Capability to automatically restart containers upon reboot of the VPS itself.
  • A certain degree of improved security by separating different apps into different containers.
  • Easy backups!
With this, it's clear that having Docker on your VPS is a must. Now, let's get started on installing Docker and taking the first steps toward a container-powered VPS. [cta_inline]

Prerequisites for Running Docker on a VPS

  • A virtual private server (VPS) running any of our available OS options. See our pricing for details.
  • A non-root user account (commands requiring escalated privileges will use sudo).

Step 1 - Installing Docker on Your VPS

Ubuntu 22.04/Debian 12

For both Ubuntu and Debian servers, the latest versions of Docker CE may not be available in the repositories. We need to install the prerequisite packages:
sudo apt-get update

sudo apt-get install curl gnupg2 apt-transport-https ca-certificates software-properties-common 
Next, we add the GPG keys, Docker repositories and finally install Docker. Here is where it gets different for both Ubuntu and Debian:


sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Then install docker:
sudo apt-get install docker-ce docker-ce-cli docker-buildx-plugin docker-compose-plugin


sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
Continue reading this article
by subscribing to our newsletter.
Subscribe now

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.