Self-managed VPS with Docker Comprehensive Yet Simple Guide

I'm trying to simplify the deployment process so i wrote this article

Uqie Rachmadie

Uqierach

6/1/2026 · 11 min read

Self-managed VPS with Docker Comprehensive Yet Simple Guide

Self-Managed VPS with Docker: A Comprehensive Yet Simple Guide

Managing your own VPS can seem daunting, but with Docker and a few essential tools, you can create a powerful, secure, and flexible environment for your applications. Whether you're a developer looking to streamline deployment or a tech enthusiast eager to learn, this guide will walk you through setting up a self-managed VPS with Docker on an Ubuntu-based server. We'll cover setting up Docker, configuring Nginx as a reverse proxy, establishing a firewall, managing Docker user permissions, integrating GitHub actions, and securing your site with Certbot.

Setting Up Docker on Your Ubuntu VPS

Start by updating your system packages to ensure everything is current:

sudo apt update && sudo apt upgrade -y

Next, install Docker using the official Docker repository to get the latest version:

sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL <https://download.docker.com/linux/ubuntu/gpg> | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] <https://download.docker.com/linux/ubuntu> focal stable"
sudo apt update
sudo apt install docker-ce -y

After installation, enable and start Docker:

sudo systemctl enable docker
sudo systemctl start docker

To avoid typing sudo every time you run Docker commands, add your user to the Docker group:

sudo usermod -aG docker $USER

Log out and back in or reboot your VPS to apply the group change.

Configuring Nginx as a Reverse Proxy

Nginx acts as a gateway between the internet and your Docker containers, routing traffic efficiently and securely.

Install Nginx:

sudo apt install nginx -y

Create a new Nginx configuration file to reverse proxy requests to your Docker container (assuming it runs on port 8080):

server {
  listen 80;
  server_name yourdomain.com www.yourdomain.com;

  location / {
    proxy_pass <http://localhost:8080>;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

Place this in /etc/nginx/sites-available/yourdomain and enable it by linking it to sites-enabled:

sudo ln -s /etc/nginx/sites-available/yourdomain /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Securing Your VPS: Firewall and SSL with Certbot

A robust firewall keeps unwanted traffic at bay. Use UFW (Uncomplicated Firewall) for simplicity:

sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw status

This setup allows SSH and web traffic through Nginx.

To secure your site with HTTPS, install Certbot and its Nginx plugin:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Certbot will automatically configure your Nginx to use SSL certificates, creating encrypted connections with your visitors.

Integrating GitHub Actions and Managing Docker Permissions

Automate deployments by granting your VPS access to GitHub repositories via GitHub Actions. Generate an SSH key on your VPS:

ssh-keygen -t ed25519 -C "your_email@example.com"

Add the generated public key (~/.ssh/id_ed25519.pub) as a deploy key in your GitHub repository settings with write access if needed. Ensure your Docker user has the proper permissions to pull, build, and run containers during automated workflows.

Configure your GitHub Actions workflow to connect via SSH using the private key stored securely as a secret in GitHub. This setup enables continuous deployment directly to your VPS.


Wrapping It Up

By following these steps—installing Docker, setting up Nginx as a reverse proxy, securing your VPS with a firewall and Certbot SSL, and enabling GitHub integration—you gain full control over your hosting environment. This self-managed approach not only enhances flexibility but also boosts your skills as a developer or system administrator.

Well, this is a minimal setup for your side projects (mine at least). It works the best at moment. :)