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. 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!
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:
Next, we add the GPG keys, Docker repositories and finally install Docker. Here is where it gets different for both Ubuntu and Debian:sudo apt-get update
sudo apt-get install curl gnupg2 apt-transport-https ca-certificates software-properties-common
Ubuntu
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -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] https://download.docker.com/linux/ubuntu \
$(. /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 containerd.io docker-buildx-plugin docker-compose-plugin
Debian
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -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] https://download.docker.com/linux/debian \
$(.
Continue reading this article
by subscribing to our newsletter.
Subscribe nowby subscribing to our newsletter.
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.