How to Install Docmost Using Docker on Rocky Linux 9

Install Docmost using Docker on Rocky Linux 9 with PostgreSQL, Redis, Caddy HTTPS, firewalld, SELinux, and health checks for a private wiki.
A polished 3D server rack, glowing container cluster, document stack, and database cylinder with cyan and green light trails on a midnight-blue background.

Install Docmost using Docker on Rocky Linux 9 to run a collaborative wiki with PostgreSQL, Redis, and automatic HTTPS. With DNS ready before you begin, the deployment takes about 15 minutes and ends at the Docmost workspace setup screen.

Prerequisites

  • A 64-bit Rocky Linux 9 VPS with at least 2 GB of RAM and 10 GB of free disk space. Reserve more disk for file uploads and Docker image updates.
  • SSH access as root, or a normal Linux account with working sudo privileges.
  • A domain such as YOUR_DOMAIN with an A record pointing to SERVER_IP. Caddy uses this hostname for a trusted TLS certificate.
  • Inbound TCP ports 80 and 443 allowed by both the VPS provider and the server firewall. Port 3000 will remain private.
  • A VPSLake Linux VPS if you need a Rocky Linux server with root access.

The commands assume a non-root SSH user and therefore use sudo. If you are logged in as root, remove sudo from each command. This setup keeps SELinux enabled and uses Rocky Linux’s DNF and firewalld.

Step 1: Confirm Rocky Linux 9 and prepare the host

Why: Confirming the release and architecture prevents Docker’s Enterprise Linux repository from being applied to the wrong system.

. /etc/os-release
printf '%s\n' "$PRETTY_NAME"
printf 'Release: %s\n' "$VERSION_ID"
uname -m
getenforce
sudo dnf upgrade -y
sudo dnf install -y ca-certificates curl dnf-plugins-core openssl

The checks should identify Rocky Linux 9, a 64-bit architecture, and an enforcing or permissive SELinux mode:

Rocky Linux 9.x (Blue Onyx)
Release: 9.x
x86_64
Enforcing

The minor release may differ. Resolve any DNF mirror, DNS, or GPG-signature failure before continuing; do not disable SELinux to make the installation proceed.

Step 2: Install Docker Engine and Compose

Why: Docker supplies the runtime, while the Compose plugin starts Docmost and its PostgreSQL, Redis, and Caddy services from one definition.

On a new VPS, remove packages that can conflict with Docker’s runtime. If this machine already runs Podman containers, inspect those workloads first and skip the removal until you have a migration plan.

sudo dnf remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine podman runc
sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
sudo dnf makecache
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker

This follows Docker’s official RHEL repository installation method using the RHEL-compatible package channel on Rocky Linux 9. Keep Docker commands under sudo; membership in the docker group grants root-equivalent access.

Check the daemon, Compose plugin, and a disposable container before creating the Docmost stack:

sudo systemctl is-active docker
sudo docker version --format 'Client {{.Client.Version}} / Server {{.Server.Version}}'
sudo docker compose version
sudo docker run --rm hello-world

Expected output is similar to this, with different patch versions as packages change:

active
Client 29.x.y / Server 29.x.y
Docker Compose version v2.x.y
Hello from Docker!

Step 3: Create the Docmost environment file

Why: The application secret protects Docmost sessions, and using one generated database password in both services prevents connection mismatches.

Generate hexadecimal values so the database password is safe inside a PostgreSQL connection URL, then create the deployment directory:

openssl rand -hex 32
openssl rand -hex 24
sudo install -d -m 0755 /opt/docmost
sudo vi /opt/docmost/.env

In vi, create /opt/docmost/.env. Put the first command’s output in APP_SECRET, the second in DB_PASSWORD, and replace YOUR_DOMAIN with the real hostname:

APP_URL=https://YOUR_DOMAIN
APP_SECRET=REPLACE_WITH_64_HEX_CHARACTERS
DB_PASSWORD=REPLACE_WITH_48_HEX_CHARACTERS

Save the file and make it readable only by root because it contains a database credential:

sudo chown root:root /opt/docmost/.env
sudo chmod 600 /opt/docmost/.env
sudo grep -E '^(APP_URL|APP_SECRET|DB_PASSWORD)=' /opt/docmost/.env | sed 's/=.*/=<set>/'

The final command should show three variables ending in <set> without revealing their values. Docmost’s official installation guide requires an APP_SECRET of at least 32 characters; openssl rand -hex 32 produces 64.

Step 4: Add Caddy and the Compose services

Why: Caddy handles public HTTPS and WebSocket forwarding, while the Compose network keeps PostgreSQL and Redis away from the internet.

Create the Caddyfile with the same hostname used in .env:

sudo vi /opt/docmost/Caddyfile

Enter this content:

YOUR_DOMAIN {
    reverse_proxy docmost:3000
}

Now create /opt/docmost/docker-compose.yml:

sudo vi /opt/docmost/docker-compose.yml

Paste the following configuration:

services:
  caddy:
    image: caddy:2
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro,Z
      - caddy_data:/data
      - caddy_config:/config
    depends_on:
      - docmost
    restart: unless-stopped

  docmost:
    image: docmost/docmost:latest
    depends_on:
      - db
      - redis
    environment:
      APP_URL: "${APP_URL}"
      APP_SECRET: "${APP_SECRET}"
      DATABASE_URL: "postgresql://docmost:${DB_PASSWORD}@db:5432/docmost"
      REDIS_URL: "redis://redis:6379"
    ports:
      - "127.0.0.1:3000:3000"
    restart: unless-stopped
    volumes:
      - docmost:/app/data/storage

  db:
    image: postgres:18
    environment:
      POSTGRES_DB: docmost
      POSTGRES_USER: docmost
      POSTGRES_PASSWORD: "${DB_PASSWORD}"
    restart: unless-stopped
    volumes:
      - db_data:/var/lib/postgresql

  redis:
    image: redis:8
    command: ["redis-server", "--appendonly", "yes", "--maxmemory-policy", "noeviction"]
    restart: unless-stopped
    volumes:
      - redis_data:/data

volumes:
  docmost:
  db_data:
  redis_data:
  caddy_data:
  caddy_config:

The :Z suffix labels the Caddy bind mount for Rocky’s SELinux policy. The loopback-only mapping prevents remote clients from reaching port 3000 directly, while the named volumes preserve pages, uploads, database records, Redis data, and certificates.

Step 5: Configure firewalld for the public endpoints

Why: The firewall should expose SSH and Caddy’s web ports, but not Docmost, PostgreSQL, or Redis as public services.

Allow SSH before reloading the firewall. If SSH uses a custom port, add that port instead of the ssh service:

sudo dnf install -y firewalld
sudo systemctl enable --now firewalld
sudo firewall-cmd --permanent --zone=public --add-service=ssh
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
sudo firewall-cmd --zone=public --list-services

The last command should include ssh, http, and https. Allow the same web ports in the VPS provider’s network firewall; Caddy needs port 80 for certificate validation and port 443 for visitors.

Step 6: Validate and start the stack

Why: Rendering the Compose file first catches an invalid YAML file or missing .env variable before images are downloaded and containers are created.

cd /opt/docmost
sudo docker compose config --quiet
sudo docker compose pull
sudo docker compose up -d
sudo docker compose ps
sudo ss -ltnp | grep -E ':(80|443|3000)\b'

config --quiet is silent when the configuration is valid. A running deployment has four services up, with port 3000 bound only to loopback:

NAME                 SERVICE   STATUS   PORTS
docmost-caddy-1      caddy     Up       0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp
docmost-docmost-1    docmost   Up       127.0.0.1:3000->3000/tcp
docmost-db-1         db        Up
docmost-redis-1      redis     Up

Compose may choose different names. The ss output should show listeners for 80, 443, and 127.0.0.1:3000, not 0.0.0.0:3000.

Verify the Docmost installation

Check the health endpoint through the public hostname. This single request tests DNS, firewalld, Caddy’s certificate, the reverse proxy, and Docmost’s HTTP listener:

curl -fsS -o /dev/null -w 'HTTP %{http_code}\n' https://YOUR_DOMAIN/api/health

Expected output:

HTTP 200

Open https://YOUR_DOMAIN in a browser. The Docmost setup page should appear; enter a workspace name, administrator details, and a unique strong password. Create a page and add a small attachment so you verify both the editor and persistent storage.

Finish with a short log review:

cd /opt/docmost
sudo docker compose logs --since=5m caddy docmost db redis

The services should not be in a restart loop, and the logs should not report an ACME certificate failure or PostgreSQL authentication error.

Troubleshooting

No match for argument: docker-ce

DNF cannot see Docker’s repository, or its metadata is stale. Re-add the RHEL-compatible repository, refresh metadata, and retry the packages:

sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
sudo dnf clean all
sudo dnf makecache
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

If the error persists, confirm that /etc/os-release reports Rocky Linux 9 and that the VPS can resolve download.docker.com.

Caddy reports permission denied for Caddyfile

The bind mount is missing its SELinux label, or the file is not readable. Confirm the Compose mount ends in :ro,Z, then recreate Caddy so Docker applies the label:

sudo chmod 644 /opt/docmost/Caddyfile
cd /opt/docmost
sudo docker compose up -d --force-recreate caddy
sudo docker compose logs --tail=40 caddy

Do not disable SELinux as a workaround.

The browser shows 502 Bad Gateway

Caddy is reachable, but Docmost is still starting or has exited. Check the application and dependency logs, then test the private listener directly:

cd /opt/docmost
sudo docker compose ps
sudo docker compose logs --tail=80 docmost db redis
curl -i http://127.0.0.1:3000/api/health

If the logs show password authentication failed for user "docmost", restore the original DB_PASSWORD in .env; PostgreSQL keeps the password from its first initialization. Do not run docker compose down -v on a live installation.

Caddy cannot obtain an HTTPS certificate

The domain may still resolve to another server, or port 80/443 may be blocked upstream. Check the A record, run sudo firewall-cmd --zone=public --list-services, allow both ports in the VPS provider firewall, and keep Caddy running while it retries the certificate request.

Hardening and maintenance

  • Keep 127.0.0.1:3000 in the Compose mapping and never publish PostgreSQL or Redis ports.
  • Back up the docmost, db_data, redis_data, caddy_data, and caddy_config volumes before upgrades or host maintenance.
  • Review image changes before applying them. From /opt/docmost, use sudo docker compose pull followed by sudo docker compose up -d.
  • After confirming the wiki works, use the VPSLake SSH hardening generator and keep .env readable only by root.

FAQ

Can I use an IP address instead of a domain?

You can test Docmost over an IP only by changing the setup to publish port 3000, but that removes Caddy’s trusted automatic certificate. A domain is the safer production choice and gives APP_URL a stable HTTPS value.

Why does the Compose file include the :Z mount option?

Rocky Linux uses SELinux labels to control what containers may read. :Z gives this private Caddy mount a container-readable label without weakening the host’s SELinux policy.

Where is the workspace data stored?

Uploaded files are stored in the docmost named volume, while PostgreSQL uses db_data. Redis and Caddy use separate volumes, so recreating containers does not remove data unless you explicitly remove the volumes.

How do I update Docmost later?

Back up the volumes, then run sudo docker compose pull and sudo docker compose up -d from /opt/docmost. Review sudo docker compose ps and the recent logs before allowing users back into the updated workspace.

Samrat Ghosh
Written by

Samrat Ghosh

Founder & Infrastructure Engineer

Samrat Ghosh is the founder of VPSLake, where he builds and runs the remote desktop and VPS hosting infrastructure the company is built on. He writes hands-on guides about RDP, Windows Server, VPS management and secure remote access - the practical documentation he wishes had…

Previous Article

tnc command: Check if a Port Is Open on Windows

Next Article

Managed vs Unmanaged VPS: Which Do You Need?

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨