How to Install Directus 12 with Docker Compose on Ubuntu 26.04 LTS
Run Directus 12 on Ubuntu 26.04 LTS with Docker Compose, PostgreSQL, Redis and an Nginx reverse proxy. Directus is now a Node.js app shipped as a Docker image.
By the end of this guide you will have Directus 12 running on your own server with PostgreSQL and Redis, started with Docker Compose and published through an Nginx reverse proxy. The steps target Ubuntu 26.04 LTS and work the same way on Ubuntu 24.04 LTS and Debian 13.
If you came here looking for Directus on a FreeBSD Apache, MySQL and PHP stack, the situation has changed completely. Directus 6 was a PHP application; every release since version 9 is a Node.js application, and the project distributes it as a Docker image. Docker Engine is published for Linux distributions only, and FreeBSD 11 itself reached end of life in 2021, so the supported way to self-host Directus today is a Linux server running Docker.
Requirements
- A server with Ubuntu 26.04 LTS (or 24.04 LTS, or Debian 13) and a user with
sudorights. The examples use a user nameddeploy. - At least 2 GB of RAM. Directus lists 0.25 vCPU and 512 MB as the bare minimum for its container and 1 vCPU with 2 GB as the recommended minimum, and you also run PostgreSQL and Redis on the same machine.
- A domain name pointing at the server, for example
cms.example.com.
Licensing in Directus 12
Directus is licensed under the Monospace Sustainable Core License. A self-hosted instance without a license key runs on the free core tier, and Directus 12 enforces the tier limits: SSO login, custom permission rules and custom LLM connections need a license. Individuals and organisations with less than $5M in annual revenue and fewer than 50 employees can apply for the Open Innovation Grant, which unlocks free use. Read the licensing overview before you plan a project around a licensed feature.
Step 1: Install Docker Engine and the Compose plugin
Install Docker from Docker's own apt repository, which supports Ubuntu 26.04 and 24.04:
sudo apt update
sudo apt install ca-certificates curl
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.ascsudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOFsudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginOn Debian 13, replace ubuntu with debian in both URLs and use $VERSION_CODENAME for the suite, as described in Docker's Debian instructions. Check the result:
sudo docker compose versionStep 2: Create the project directory
Keep the Compose file, uploads, extensions and database files together in one directory:
sudo mkdir -p /opt/directus
sudo chown deploy:deploy /opt/directus
cd /opt/directus
mkdir -p uploads extensions data/databaseThe Directus container does not run as root, so it needs write access to the two bind-mounted directories. Give them to UID 1000, the user inside the image:
sudo chown -R 1000:1000 uploads extensionsGenerate two random values, one for the Directus SECRET (used to sign access tokens) and one for the database password:
openssl rand -hex 32
openssl rand -hex 24Create /opt/directus/.env and paste the values in. Docker Compose reads this file automatically and substitutes the variables in the next step:
DIRECTUS_SECRET=paste-the-first-value-here
DB_PASSWORD=paste-the-second-value-here
PUBLIC_URL=https://cms.example.comchmod 600 /opt/directus/.envStep 3: Write the Compose file
Create /opt/directus/docker-compose.yml. This follows the PostgreSQL, Redis and local-files example from the Directus deployment documentation, with the version pinned and the port bound to localhost so that only Nginx can reach it:
services:
database:
image: postgis/postgis:17-3.5
restart: unless-stopped
volumes:
- ./data/database:/var/lib/postgresql/data
environment:
POSTGRES_USER: "directus"
POSTGRES_PASSWORD: "${DB_PASSWORD}"
POSTGRES_DB: "directus"
healthcheck:
test: ["CMD", "pg_isready", "--host=localhost", "--username=directus"]
interval: 10s
timeout: 5s
retries: 5
start_interval: 5s
start_period: 30s
cache:
image: redis:7
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "[ $$(redis-cli ping) = 'PONG' ]"]
interval: 10s
timeout: 5s
retries: 5
start_interval: 5s
start_period: 30s
directus:
image: directus/directus:12.6.1
restart: unless-stopped
ports:
- 127.0.0.1:8055:8055
volumes:
- ./uploads:/directus/uploads
- ./extensions:/directus/extensions
depends_on:
database:
condition: service_healthy
cache:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget --spider -q http://localhost:8055/server/ping || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_interval: 5s
start_period: 30s
environment:
SECRET: "${DIRECTUS_SECRET}"
DB_CLIENT: "pg"
DB_HOST: "database"
DB_PORT: "5432"
DB_DATABASE: "directus"
DB_USER: "directus"
DB_PASSWORD: "${DB_PASSWORD}"
CACHE_ENABLED: "true"
CACHE_AUTO_PURGE: "true"
CACHE_STORE: "redis"
REDIS: "redis://cache:6379"
PUBLIC_URL: "${PUBLIC_URL}"
IP_TRUST_PROXY: "true"
LICENSE_KEY: ""A few points about this file:
- Pin the version.
12.6.1was the newest image tag on Docker Hub when this guide was written. Directus recommends a fixed tag in production so that a container restart never upgrades you by accident. PUBLIC_URLmust be the exact address users will open. Directus builds links and asset URLs from it, and a license key binds to it on first use.IP_TRUST_PROXYdefaults tofalsein Directus 12. Behind a reverse proxy you have to enable it, otherwise Directus sees every request as coming from the proxy.LICENSE_KEYstays empty for the core tier.
Step 4: Start Directus
cd /opt/directus
sudo docker compose up -d
sudo docker compose psAfter half a minute all three services should show healthy. Database migrations run automatically on first start. Test the liveness endpoint from the server:
curl http://127.0.0.1:8055/server/pingThe answer is pong. If the directus service keeps restarting, read its log with sudo docker compose logs directus; a wrong database password or an unwritable uploads directory are the usual causes.
Step 5: Publish it with Nginx and TLS
Install Nginx and Certbot, then create a server block that forwards requests, including WebSocket upgrades, to the container:
sudo apt install nginx certbot python3-certbot-nginxSave this as /etc/nginx/sites-available/directus:
server {
listen 80;
server_name cms.example.com;
client_max_body_size 100m;
location / {
proxy_pass http://127.0.0.1:8055;
proxy_http_version 1.1;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}sudo ln -s /etc/nginx/sites-available/directus /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d cms.example.comAllow ports 80 and 443 in your firewall. Port 8055 does not need to be opened because it listens on localhost only.
Step 6: Create the admin account
Open https://cms.example.com. On first access Directus shows an onboarding screen in the Studio where you set the email address and password of the first administrator. For scripted deployments you can skip the screen by adding ADMIN_EMAIL and ADMIN_PASSWORD to the environment section before the first start.
Upgrades and backups
Directus publishes a release roughly once a month. Before each upgrade, read the breaking-changes list in the upgrade documentation, then change the image tag in docker-compose.yml and recreate the container:
cd /opt/directus
sudo docker compose pull
sudo docker compose up -dBack up three things: a database dump, the uploads directory and the .env file. A dump can be taken while the stack is running:
sudo docker compose exec database pg_dump -U directus directus > directus-$(date +%F).sqlFrequently asked questions
Can I run Directus without Docker, for example on FreeBSD?
Directus is also published on npm, and that route needs Node.js 26 or newer since version 12.6. The project documents and tests the Docker image, though, and the image already contains every optional database and storage driver. On FreeBSD you would be on your own with native Node.js modules, so a small Linux virtual machine with Docker is the practical choice.
Do I have to use PostgreSQL?
No. Directus supports the long-term-support versions of PostgreSQL, MySQL, MariaDB, SQLite, MS SQL Server, CockroachDB and OracleDB. Change DB_CLIENT and the connection variables accordingly. SQLite is fine for trying things out, but the project recommends a database server and Redis for production.
Is Redis required?
Not for a single instance. Redis is recommended for caching and becomes mandatory once you run several Directus containers behind a load balancer. To run without it, remove the cache service and the four CACHE_* and REDIS variables.
Why does my monitoring get a 403 from /server/health?
In Directus 12 that endpoint requires authentication. Use /server/ping for liveness checks and load-balancer probes; call /server/health only with the static token of a dedicated user when you need dependency status.