DEV Community

Cover image for How to install Dokploy on an Ubuntu VPS securely
Fernando Chagas for Nuvits

Posted on Originally published at nuvits.net

How to install Dokploy on an Ubuntu VPS securely

This tutorial installs Dokploy v0.31.4 on an Ubuntu 24.04 VPS without ever exposing the initial admin sign-up page to the public internet. Before running the official installer, we block external access to port 3000 in the iptables raw table (ahead of Docker Swarm's NAT rules), create the first admin account through an SSH tunnel, move the dashboard behind a custom domain with Traefik HTTPS, and finish with S3 backups and safe updates.

All commands, service names, secrets, and paths below were verified directly against Dokploy v0.31.4 upstream source (install.sh, traefik-setup.ts, web-server.ts, and encryption.ts).

What you will need

  • A 64-bit Ubuntu 24.04, Ubuntu 22.04, or Debian 12 VPS with key-based SSH access. Dokploy does not yet list Debian 13 among tested operating systems.
  • A domain where you can create A DNS records. Examples below use dokploy.example.com.
  • Ports 80, 443, and 3000 free on the server (the installer aborts if anything is already listening on any of them).

The official Dokploy documentation lists a minimum of 2 GB RAM and 30 GB free disk space. In production, that baseline only covers the panel itself plus one light service: Docker image builds and application databases quickly consume extra memory and disk. A 4 vCPU / 8 GB RAM VPS gives comfortable headroom for multiple apps, PostgreSQL, and builds without slowing down the dashboard.

If you want to skip manual setup, Nuvits also offers Dokploy preinstalled on Linux VPS plans running Ubuntu 22.04, Ubuntu 24.04, or Debian 12, with port 3000 already blocked from the public internet and initial access over the same SSH tunnel shown here.

Why you should not run the default installer blindly

The one-liner on the homepage (curl -sSL https://dokploy.com/install.sh | sh) initializes a single-node Docker Swarm with three core containers — dokploy, dokploy-postgres (postgres:16), and dokploy-traefik (traefik:v3.7.19) — and publishes port 3000 in host mode on every interface. That leaves three immediate gaps:

  • The first visitor to port 3000 becomes root admin. Until you register the first account, any scanner hitting http://IP:3000 can claim the dashboard and gain control over /var/run/docker.sock on the host.
  • Initial registration happens over plain HTTP. Without an SSH tunnel or HTTPS, your admin credentials cross the internet unencrypted.
  • ufw does not block Docker Swarm's published port 3000. Docker inserts its own iptables rules ahead of ufw, so denying 3000 in ufw alone still leaves the dashboard open to the internet — see The Docker port stays open with ufw.

Dokploy v0.31.4 architecture on an Ubuntu VPS showing Traefik on ports 80 and 443, port 3000 blocked in the iptables raw table, initial access over an SSH tunnel, and dokploy plus dokploy-postgres on dokploy-network

The steps below close all three gaps before the first container starts.

1. Prepare the server, SSH, and base firewall

If your VPS starts with root access, create an operational user with sudo and copy your public SSH key:

adduser deploy
usermod -aG sudo deploy
install -d -m 700 -o deploy -g deploy /home/deploy/.ssh
install -m 600 -o deploy -g deploy ~/.ssh/authorized_keys /home/deploy/.ssh/
Enter fullscreen mode Exit fullscreen mode

Open a second SSH session as deploy and verify sudo -v works before locking down SSH. Run the remaining commands as deploy.

Disable password authentication and direct root SSH login:

sudo nano /etc/ssh/sshd_config.d/10-hardening.conf
Enter fullscreen mode Exit fullscreen mode

```text /etc/ssh/sshd_config.d/10-hardening.conf
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no




Test the SSH configuration and restart the daemon:



```bash
sudo sshd -t
sudo systemctl restart ssh
Enter fullscreen mode Exit fullscreen mode

Allow only SSH, HTTP, and HTTPS (including UDP 443 for Traefik HTTP/3) in ufw:

sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443
sudo ufw enable
sudo ufw status
Enter fullscreen mode Exit fullscreen mode

If your provider also has an external cloud firewall in the control panel, allow only 22/tcp, 80/tcp, and 443 (TCP and UDP) there as well.

2. Block external access to port 3000 before installing

The dokploy Swarm service created by install.sh binds --publish published=3000,target=3000,mode=host on all addresses. To keep port 3000 unreachable from outside while still allowing localhost (your SSH tunnel) and internal Docker bridges, install a small filter in the iptables and ip6tables raw table, which runs before Docker's NAT rules:

sudo tee /usr/local/sbin/dokploy-port-guard >/dev/null <<'EOF'
#!/bin/sh
set -e
for table in iptables ip6tables; do
  $table -t raw -N DOKPLOY-GUARD 2>/dev/null || true
  $table -t raw -F DOKPLOY-GUARD
  for iface in lo docker+ br-+ veth+; do
    $table -t raw -A DOKPLOY-GUARD -i "$iface" -j RETURN
  done
  $table -t raw -A DOKPLOY-GUARD -p tcp --dport 3000 -j DROP
  $table -t raw -C PREROUTING -j DOKPLOY-GUARD 2>/dev/null || $table -t raw -I PREROUTING -j DOKPLOY-GUARD
done
EOF
sudo chmod 700 /usr/local/sbin/dokploy-port-guard
Enter fullscreen mode Exit fullscreen mode

Create a systemd unit so the guard is restored automatically on every reboot before docker.service starts:

sudo tee /etc/systemd/system/dokploy-port-guard.service >/dev/null <<'EOF'
[Unit]
Description=Block external access to Dokploy port 3000
DefaultDependencies=no
After=local-fs.target systemd-modules-load.service
Before=network-pre.target docker.service
Wants=network-pre.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/sbin/dokploy-port-guard

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now dokploy-port-guard.service
sudo iptables -t raw -L DOKPLOY-GUARD -n -v
Enter fullscreen mode Exit fullscreen mode

Confirm the output lists RETURN rules for local/Docker interfaces followed by DROP on tcp dpt:3000.

3. Download and run the pinned Dokploy installer

Fetch the installer from the v0.31.4 GitHub release so you control the exact version and can inspect the script before running it:

curl -fsSL https://github.com/Dokploy/dokploy/releases/download/v0.31.4/install.sh -o dokploy-install.sh
less dokploy-install.sh
Enter fullscreen mode Exit fullscreen mode

When executed as root, the script:

  1. Verifies that ports 80, 443, and 3000 are unused.
  2. Installs Docker (28.5.0, held with apt-mark hold to prevent accidental upgrades) if Docker is not already present.
  3. Initializes Docker Swarm (docker swarm init) and creates the attachable overlay network dokploy-network.
  4. Creates /etc/dokploy with mode 755 (root-only writes) and generates two random Docker Secrets: dokploy_postgres_password and dokploy_auth_secret.
  5. Starts the Swarm services dokploy-postgres (postgres:16) and dokploy (dokploy/dokploy:v0.31.4), plus the standalone container dokploy-traefik (traefik:v3.7.19).

Run the installer with the pinned version:

sudo DOKPLOY_VERSION=v0.31.4 bash dokploy-install.sh
Enter fullscreen mode Exit fullscreen mode

If your VPS has multiple IP addresses (for instance, a private network interface or an active VPN), pass ADVERTISE_ADDR after sudo and before bash (sudo DOKPLOY_VERSION=v0.31.4 ADVERTISE_ADDR=<interface-ip> bash dokploy-install.sh) so sudo preserves the variable and Swarm binds to the interface you expect.

Wait 15 to 30 seconds and verify all three components are running:

sudo docker service ls
sudo docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'
Enter fullscreen mode Exit fullscreen mode

You should see dokploy and dokploy-postgres at 1/1 replicas in docker service ls, and dokploy-traefik listening on ports 80 and 443. At the end, the script prints http://IP:3000 — that public URL will not load from outside because dokploy-port-guard is blocking it, which is exactly what we want.

4. Create the admin account through an SSH tunnel

On your local machine, open an SSH tunnel to port 3000:

ssh -N -L 3000:127.0.0.1:3000 deploy@VPS_IP
Enter fullscreen mode Exit fullscreen mode

Keep that terminal running, open http://localhost:3000 in your browser, and create the administrator account using a strong password stored in your password manager. Once the first account is created, Dokploy closes public registration.

Right after signing in:

  1. Go to Settings → Profile, enable Two-Factor Authentication (2FA), and save the recovery codes outside the VPS.
  2. Clean up the downloaded installer on the VPS (rm -f ~/dokploy-install.sh).

5. Put the dashboard behind a domain with Traefik HTTPS

In your DNS provider, create an A record pointing dokploy.example.com to the VPS's public IPv4 address. Verify propagation before requesting a certificate:

dig +short dokploy.example.com A
Enter fullscreen mode Exit fullscreen mode

Once DNS resolves to your VPS IP:

  1. Inside the Dokploy panel (still via the SSH tunnel), open Settings → Web Server → Server Domain.
  2. Set Domain to dokploy.example.com.
  3. Enter a real e-mail address in Let's Encrypt Email for certificate notices.
  4. Enable HTTPS, select Let's Encrypt as the certificate provider, and save.

Dokploy writes the dynamic route under /etc/dokploy/traefik/dynamic, and dokploy-traefik issues the TLS certificate automatically. Verify from outside the VPS:

curl -I https://dokploy.example.com
Enter fullscreen mode Exit fullscreen mode

Expect HTTP/2 200 (or an HTTPS redirect to /login). You can now close the SSH tunnel and use the panel over HTTPS while keeping dokploy-port-guard enabled — port 3000 stays closed to the internet, and the SSH tunnel remains available as emergency access if DNS or Traefik ever breaks.

6. Back up Dokploy (database, /etc/dokploy, and encryption key)

Dokploy's state lives in three places:

  • The panel PostgreSQL database (dokploy-postgres, volume dokploy-postgres).
  • The /etc/dokploy directory (Traefik configuration, SSH keys created by Dokploy, and project/compose files).
  • The encryption secret used to protect stored credentials in PostgreSQL (dokploy_auth_secret, derived with AES-256-GCM in encryption.ts).

Scheduled S3 backups (recommended)

The cleanest approach for production is Dokploy's built-in web server backup:

  1. In Settings → S3 Destinations, add an S3-compatible bucket (Cloudflare R2, Backblaze B2, AWS S3, or an external MinIO instance).
  2. In Settings → Web Server → Backups, create a daily schedule pointing to that bucket and enable Include encryption key.

With that option enabled, Dokploy builds a .zip containing a custom-format dump of dokploy-postgres (pg_dump -Fc), the /etc/dokploy tree, and encryption.key (the derived decryption key required to read stored secrets after restoring to a new VPS, without exporting the raw BETTER_AUTH_SECRET).

Manual CLI backup before major changes

Before upgrading or testing risky changes, you can also grab a quick manual snapshot of the database, /etc/dokploy, and the dokploy_auth_secret Swarm secret (stored outside /etc/dokploy):

PG_CID=$(sudo docker ps --filter "name=dokploy-postgres" --filter "status=running" -q | head -n 1)
DOKPLOY_CID=$(sudo docker ps --filter "label=com.docker.swarm.service.name=dokploy" --filter "status=running" -q | head -n 1)
mkdir -p ~/backups-dokploy && chmod 700 ~/backups-dokploy
(
  umask 077
  sudo docker exec "$PG_CID" pg_dump -Fc -U dokploy -d dokploy > ~/backups-dokploy/dokploy-db-$(date +%F).dump
  sudo tar czf ~/backups-dokploy/etc-dokploy-$(date +%F).tar.gz -C /etc dokploy
  sudo docker exec "$DOKPLOY_CID" cat /run/secrets/dokploy_auth_secret > ~/backups-dokploy/dokploy-auth-secret.txt
)
Enter fullscreen mode Exit fullscreen mode

Copy those files off the VPS with scp, store dokploy-auth-secret.txt separately from the dump in your password manager, and delete it from the VPS (rm -f ~/backups-dokploy/dokploy-auth-secret.txt) — without it, a manual dump restored on another VPS cannot decrypt credentials stored in the panel. Keep in mind this backs up the Dokploy panel itself — configure separate S3 backup schedules for each application database you deploy.

7. Update Dokploy safely

You can upgrade in two ways — always after checking the release notes at github.com/Dokploy/dokploy/releases and verifying your latest backup:

  • From the dashboard: when a new stable release is available, Dokploy displays an update notice and runs docker service update --force --image dokploy/dokploy:<version> dokploy.
  • From the terminal with a pinned tag:
sudo docker pull dokploy/dokploy:v0.31.4
sudo docker service update --image dokploy/dokploy:v0.31.4 dokploy
Enter fullscreen mode Exit fullscreen mode

Replace v0.31.4 with the target release tag. Swarm pulls the new image and replaces only the dokploy service, leaving dokploy-postgres, dokploy-traefik, volumes, and your running apps untouched. Confirm the active image after a minute:

sudo docker service inspect dokploy --format '{{.Spec.TaskTemplate.ContainerSpec.Image}}'
Enter fullscreen mode Exit fullscreen mode

Common issues after installation

  • Error: something is already running on port 80 (or 443/3000) during installation: check what owns the port with sudo ss -tulnp | grep -E ':(80|443|3000) ' and stop/remove pre-existing web servers (apache2, nginx, or caddy) before running install.sh.
  • Dashboard domain shows a certificate error or Traefik 404: confirm dig +short dokploy.example.com A returns the VPS IPv4 (disable CDN orange-cloud proxying during initial issuance or use DNS-01) and inspect sudo docker logs --tail=80 dokploy-traefik.
  • Builds freeze or exit with OOMKilled: parallel Next.js, Rust, or Nuxt builds can spike memory fast. On servers under 8 GB RAM or hosting multiple stacks, limit concurrent builds or move up a memory tier.

Next steps


Originally published at https://nuvits.net/en/blog/install-dokploy-ubuntu-vps

Top comments (0)