2026-11-19 · nocodb · docker · postgres · self-hosting
Self-Host NocoDB with Docker Compose and PostgreSQL
Run NocoDB in Docker with PostgreSQL and Redis: compose file, NC_SITE_URL, secure attachments, reverse proxy, backups, and update steps.
- Total RAM
- 838.8 MB
- Startup
- 112.8 s
- Port
- 8080
- HTTP
- 200
nocodb 765.1 MB
· db 69.7 MB
· redis 4.0 MB
What NocoDB does and what it needs
NocoDB turns any SQL database into a smart spreadsheet UI — grid, gallery, form, kanban, and calendar views on top of Postgres, MySQL, or SQLite. You get Airtable-style collaboration, shareable views, role-based access, REST APIs, and an app store for Slack, SMTP, and S3 integrations without giving up ownership of the data.
The upstream project ships a single image (nocodb/nocodb) that runs the community and enterprise editions. The official noco.sh installer wires up NocoDB with bundled PostgreSQL, Redis, Minio, and Traefik. This guide keeps the same shape but drops Traefik and Minio so the stack boots standalone behind whatever reverse proxy you already run.
NocoDB itself is stateless — the app container only needs a writable /usr/app/data volume for the generated db.json and any local attachments. All real state lives in PostgreSQL. Redis is optional but recommended for caching and multi-replica setups.
The project does not publish a minimum RAM figure. Practical sizing depends on workload: an idle instance with a handful of bases runs comfortably on a small VPS, while heavy imports, large attachment uploads, and many concurrent editors push memory and CPU up. Watch container memory during the first week and scale accordingly.
Prerequisites, ports, and volume constraints
- Docker Engine 24+ with the Compose V2 plugin (
docker compose version). - A host with a public DNS record if you plan to terminate TLS (e.g.
nocodb.example.com). - Port
8080is the app’s HTTP port inside the container. We bind it to127.0.0.1:8080so only the local reverse proxy can reach it. - Two named volumes:
nocodb_data(app data,db.json, local attachments) andnocodb_db(PostgreSQL data directory). - A
nocodb/db.jsonfile mounted into the container at/usr/app/data/db.json— this is how NocoDB learns the Postgres connection. The official installer generates it withumask 077; do the same.
If you’re testing without a domain, either SSH-tunnel to the bound port (ssh -L 8080:127.0.0.1:8080 user@host) or temporarily change the port mapping to 8080:8080 and open the firewall. Revert before going live.
Production Docker Compose setup
Create the project directory and lock down permissions first — db.json holds the Postgres password.
mkdir -p ~/nocodb/nocodb && cd ~/nocodb
umask 077
Generate secrets once and keep them in .env:
cat <<'EOF' > .env
# Public URL used for email links, webhooks, and OAuth redirects
NC_SITE_URL=https://nocodb.example.com
# Postgres
DB_USER=nocodb
DB_NAME=nocodb
DB_PASSWORD=REPLACE_WITH_OPENSSL_RAND_HEX_32
# JWT signing secret for auth tokens
NC_AUTH_JWT_SECRET=REPLACE_WITH_OPENSSL_RAND_HEX_32
# Optional
TZ=UTC
EOF
# Fill the two REPLACE_* values with real secrets
sed -i "s|REPLACE_WITH_OPENSSL_RAND_HEX_32|$(openssl rand -hex 32)|g" .env
chmod 600 .env
Write nocodb/db.json using the same password. NocoDB reads this file at boot and ignores NC_DB when it’s present:
DB_PASSWORD=$(grep '^DB_PASSWORD=' .env | cut -d= -f2-)
cat <<EOF > nocodb/db.json
{
"client": "pg",
"connection": {
"host": "db",
"port": "5432",
"user": "nocodb",
"password": "${DB_PASSWORD}",
"database": "nocodb"
}
}
EOF
chmod 600 nocodb/db.json
Now the compose file:
cat <<'EOF' > compose.yml
services:
nocodb:
image: nocodb/nocodb:latest
restart: unless-stopped
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
environment:
NC_DB: "pg://db:5432?u=${DB_USER:-nocodb}&p=${DB_PASSWORD}&d=${DB_NAME:-nocodb}"
NC_REDIS_URL: redis://redis:6379
NC_SITE_URL: ${NC_SITE_URL:-http://localhost:8080}
NC_AUTH_JWT_SECRET: ${NC_AUTH_JWT_SECRET}
NC_SECURE_ATTACHMENTS: "true"
NC_DISABLE_MUX: "true"
NODE_OPTIONS: --max-old-space-size=1024
TZ: ${TZ:-UTC}
ports:
- "127.0.0.1:8080:8080"
volumes:
- nocodb_data:/usr/app/data
healthcheck:
test: ["CMD-SHELL", "wget -q --tries=1 --spider http://localhost:8080/api/v1/health || exit 1"]
interval: 15s
timeout: 5s
retries: 10
start_period: 30s
networks:
- nocodb-network
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: ${DB_USER:-nocodb}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME:-nocodb}
TZ: ${TZ:-UTC}
volumes:
- nocodb_db:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-nocodb} -d ${DB_NAME:-nocodb}"]
interval: 10s
timeout: 5s
retries: 10
networks:
- nocodb-network
redis:
image: redis:7-alpine
restart: unless-stopped
command: ["redis-server", "--save", "", "--appendonly", "no"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 5
networks:
- nocodb-network
networks:
nocodb-network:
driver: bridge
volumes:
nocodb_data:
nocodb_db:
EOF
Bring it up:
docker compose up -d
docker compose ps
docker compose logs -f nocodb
Wait for the healthcheck to flip to healthy, then hit http://127.0.0.1:8080/dashboard from the host (or via SSH tunnel) to confirm the UI loads before wiring the proxy.
Reverse proxy, HTTPS, and first-run hardening
NocoDB is a single-page app that talks to /api/v1/* and /dashboard over the same origin. Two things matter for the proxy:
- Forward the real scheme and host.
NC_SITE_URLmust match the public URL exactly (includinghttps://). If the proxy terminates TLS, passX-Forwarded-Proto: httpsandX-Forwarded-Hostso generated links, password resets, and webhook callbacks resolve correctly. - Allow large uploads. Attachments and CSV imports go through the same origin. Set
client_max_body_size(Nginx) orrequest_bodylimits (Caddy handles this by default) to at least50m.
Caddy example (/etc/caddy/Caddyfile):
nocodb.example.com {
encode gzip
request_body {
max_size 100MB
}
reverse_proxy 127.0.0.1:8080 {
header_up X-Forwarded-Proto {scheme}
header_up X-Forwarded-Host {host}
}
}
Nginx example:
server {
listen 443 ssl http2;
server_name nocodb.example.com;
client_max_body_size 100m;
location / {
proxy_pass http://127.0.0.1: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;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300s;
}
}
First-run hardening. The first account you create at /dashboard becomes the super admin. Do this immediately after the stack is healthy, before you point DNS at the box, or restrict the port to your IP with ufw allow from <your-ip> to any port 8080 until the admin exists. Once signed in, invite teammates through the UI rather than sharing the admin account. NC_SECURE_ATTACHMENTS=true (already set) forces signed URLs for attachment downloads — leave it on.
Updating, backups, and common pitfalls
Update:
cd ~/nocodb
docker compose pull
docker compose up -d
docker compose logs -f nocodb
NocoDB runs schema migrations on boot. Take a Postgres dump first — a failed migration without a backup is painful to unwind.
Backup:
# Postgres dump (the source of truth)
docker compose exec -T db pg_dump -U nocodb nocodb | gzip > backup-$(date +%F).sql.gz
# App data volume (db.json + local attachments)
docker run --rm -v nocodb_nocodb_data:/data -v "$PWD":/backup alpine \
tar czf /backup/nocodb-data-$(date +%F).tgz -C /data .
Restore by piping the dump back into psql and extracting the tarball into the volume. Keep both artifacts — the volume alone is not enough because attachments may live there while rows live in Postgres.
Pitfalls from the docs:
NC_SITE_URLmismatch. If you change the domain or move from HTTP to HTTPS, updateNC_SITE_URLand restart. Otherwise invitation emails, password resets, and OAuth redirects point at the old URL. The official installer regeneratesdocker.envon every run for exactly this reason.db.jsonpermissions. The installer setsumask 077before writingdb.jsonbecause it contains the Postgres password in plaintext. If you copy the file around or restore from backup, re-checkchmod 600— a world-readabledb.jsonon a shared host leaks your database.- Redis persistence. The compose above runs Redis with
--save "" --appendonly nobecause NocoDB uses it as a cache, not a store. If you enable persistence, you’re backing up data NocoDB can rebuild from Postgres anyway — skip it and keep the volume small.
Measured in our sandbox run: total memory 838.8 MB (sum of per-container peaks over a 30s idle window after startup) across 3 containers; largest container 765.1 MB; published port(s) 8080; HTTP probe returned 200. The run took 112.8s including the image download. Required secret(s) DB_PASSWORD, NC_AUTH_JWT_SECRET were generated for the test run, as the tutorial instructs. Container breakdown: nocodb 765.1 MB, db 69.7 MB, redis 4.0 MB.
Verification: we ran this docker-compose stack in a disposable Docker environment and recorded the measurements above. They describe that run, not a guarantee for your host.