Running Zitadel with Docker Compose for staging and small production
Docker Compose gives a team a self-hosted Zitadel stack inside its own infrastructure: the Zitadel API and login containers, a PostgreSQL service, a reverse proxy in front, and the configuration files that tie them together. It suits a staging environment or a small production system where one or two hosts are enough and the team wants a first deployment it can read, change and recreate. The Zitadel documentation on self-hosting lists three supported routes: Linux and macOS binaries, Docker Compose, and Kubernetes. For high availability, it recommends a Kubernetes cluster with the official Helm chart, so Compose is the route to take when availability across several nodes is not yet a requirement.
Settle the database version before writing any Compose file. Zitadel uses PostgreSQL 14 through 18, so pin a supported image tag in the Compose file and confirm it against the database documentation for the Zitadel release you plan to run. Also confirm the Zitadel image tag against the GitHub releases page, since a Compose file copied from an older guide can point at a version you do not intend to run. Decide early where the masterkey, database password and TLS certificates will live, because those files are mounted into containers and are the first things a security reviewer will ask about.
Choose Compose when one team runs the stack, a single host or a small set of hosts is acceptable, and a restart or host replacement during planned maintenance is tolerable. Move to Kubernetes with the Helm chart when you need rolling upgrades without downtime, several replicas behind a load balancer, or cluster-level controls such as network policy and secrets management that your platform team already operates. Illustrative example: a staging instance used by a product team for integration tests fits Compose well, while a customer-facing workforce login that must survive a node failure belongs on Kubernetes. Ask your platform or security team which availability target applies before you commit to either route.
Request and data flow in a Compose deployment
Traffic starts at the browser or client and enters through the reverse proxy, which terminates TLS and forwards requests to the Zitadel API and Login containers. Both containers read the masterkey and configuration files at startup, and both use the same PostgreSQL service for data. Everything inside the host boundary is yours to secure, so check that only the proxy port is published, that the database port stays off the public network, and that the masterkey file has restricted permissions.
Client requests flow through the proxy into Zitadel containers and PostgreSQL inside the host boundary.
Compose options and when each fits
This table compares the layout choices a team makes before writing a Compose file for Zitadel: host layout, database, reverse proxy and environment. Read each row against your environment, and treat the trade-offs as the questions to settle before the build starts.
| Decision | Option | When it fits | Trade-off |
|---|---|---|---|
| Host layout | Single host, all containers together | Staging, demos, or a small production instance where one failure domain is acceptable | One server failure takes down identity, the database and the proxy together, and recovery depends on that host's backups |
| Host layout | Separate database host | Production where the database needs its own patching window, storage and backup schedule | Adds a network hop, firewall rules and a second system to secure and monitor |
| Database | Bundled PostgreSQL container | Staging, proofs of concept, or an isolated test environment with disposable data | You own volume backups, minor upgrades, TLS settings and recovery testing for the database yourself |
| Database | Externally managed PostgreSQL | Production that already runs a supported PostgreSQL service with its own backup, failover and access controls | Requires pre-provisioned roles and a database, and network and TLS settings to be confirmed with the database team |
| Reverse proxy | Nginx, Traefik or Caddy in front of Zitadel | Production, where TLS termination, HTTP/2 handling and the Host header must match your domain plan | Each proxy has its own configuration for HTTP/2 and gRPC upstreams, so choose one and test it against the sibling guide for that proxy |
| Reverse proxy | No proxy, ports exposed directly | Local testing only | Leaves TLS, certificates and the external domain settings unresolved, so it is not a production layout |
| Environment | Staging | Testing upgrades, configuration changes, SSO integrations and the masterkey procedure before production | Staging data and secrets should be kept separate from production, or the masterkey and credentials will be shared by accident |
| Environment | Small production | A single customer-facing instance with a tested backup and restore path and a named operator | Single-host operation means changes carry more risk, so confirm the maintenance window, rollback steps and when to graduate to Kubernetes |
Setup sequence for a Compose deployment
This sequence takes a host from bare DNS names to a verified Zitadel console, login page and discovery endpoint, with each phase finishing before the next one starts. Following the order matters because the setup phase must complete before the API serves traffic.
Prepare the host and DNS names
Confirm the Linux host has Docker Engine and the Compose v2 plugin installed, that its clocks are synchronized, and that the public hostname for Zitadel resolves to the host or to the proxy in front of it. Decide the external domain, port and whether the external address uses HTTPS, because these values are written into configuration and are hard to change later. Check that the host can reach the certificate authority or the internal PKI you plan to use. The step is done when a DNS lookup from a client machine returns the expected address and the host passes a basic outbound connectivity test.
Generate and store the masterkey outside the repository
Generate the 32-byte masterkey that Zitadel uses to encrypt secrets at rest, using a cryptographically secure random source, and store it in a secrets manager or a root-owned file with restricted permissions. Keep it out of the Compose file, the Git repository and shell history. Record who holds the backup copy, because the key cannot be rotated in place. The step is done when the key file exists outside the project directory, its length is 32 bytes, and the Compose configuration references it by file or secret rather than by value. See the masterkey sibling page for generation and storage details.
Write the Compose and configuration files
Create the project directory with a
docker-compose.ymlthat defines the PostgreSQL service, the Zitadel API service and the Login service, along with a configuration file that sets the external domain, port, TLS mode and database connection values. Pin image tags to a specific released version rather than a floating tag, and take the version from the official releases list. Mount the masterkey as a secret or file, not as an environment variable in plain text. The step is done whendocker compose configrenders without errors and the rendered output contains no literal secret values.Start PostgreSQL and wait for health
Start only the PostgreSQL service and confirm it becomes healthy before anything else starts. Use a health check in the Compose file so dependent services wait on a healthy status, and create a database user and database dedicated to Zitadel. Confirm the PostgreSQL version is within the range Zitadel supports, which the database documentation lists. The step is done when
docker compose psshows the database as healthy and a test connection with the Zitadel credentials succeeds from inside the Compose network.Run the setup phase before the API serves traffic
Run the Zitadel setup phase as a one-off command against the database. This creates the schema, the first instance and the initial administrator, so it must finish successfully before the API starts. Capture the output and store the initial administrator credentials in your secrets manager, then rotate that password after first sign-in. Do not let the API container run setup on every start in a long-lived stack. The step is done when the setup command exits with status zero and the logs show the schema and instance were created without errors.
Start the API and Login containers
Bring up the Zitadel API container and the separate Login container once setup has succeeded. Both services should start with the same configuration and masterkey, and the Login service must reach the API over the internal network. Check that each container stays running after startup rather than restarting in a loop. The step is done when
docker compose psshows both services running, the API health endpoint responds on its internal port, and the logs contain no database or masterkey errors.Configure the reverse proxy and TLS
Place a reverse proxy in front of the API and Login services, route the external domain to them, and configure TLS with a certificate issued for that hostname. Gateway routing for gRPC and HTTP/2 needs explicit configuration, so follow the reverse proxy sibling page for the exact upstream settings and the Host and Forwarded headers. Confirm that the external address and port in Zitadel match what the proxy presents to clients. The step is done when a request to the external HTTPS address returns a valid certificate chain and a response from the API, not an error about the instance or the host.
Verify the console, login page and discovery endpoint
Test the deployment from an external client. Open the console and sign in with the administrator account, open the hosted login page and complete a sign-in flow, and request the OpenID Connect discovery document at the well-known path for the instance. Check that the issuer value in the discovery document matches the external HTTPS address exactly. If the issuer differs or the console reports that the instance was not found, correct the external domain settings and rerun the affected step. The step is done when all three checks pass from a browser outside the host and the issuer value is recorded in your deployment notes. For domain troubleshooting, see the custom domains sibling page.
Security considerations for a Compose host
A Compose deployment puts the Zitadel API, login, database and secrets on one host, so the controls are concentrated there. The six concerns below cover how secrets are stored, how the database is exposed, how traffic is encrypted, who can reach the console, how images are kept current, and how backups stay usable.
Keep the masterkey out of the repository
The masterkey encrypts Zitadel secrets at rest, so anyone holding it and the database can read those secrets. Keep it in a .env file or secret file readable only by the deployment user, excluded from version control, and never typed inline in a command that lands in shell history. Check that the Compose file references the file rather than embedding the value.
Keep database credentials off the command line
Database passwords passed as arguments to docker run or psql appear in shell history and process listings. Store them in the same protected environment file, use a dedicated database role for Zitadel rather than the superuser, and rotate the password through the file rather than by editing commands. Confirm with git status that no secret file is staged.
Restrict PostgreSQL to the internal network
The database service should attach only to the internal Compose network and publish no host port, so only the Zitadel containers can reach it. Review the ports entries in the Compose file and confirm with a scan from outside the host that port 5432 is closed. Anything else on the host that needs the database should go through an explicit, documented path.
Encrypt proxy and database traffic
TLS terminates at the reverse proxy for clients, and the connection from Zitadel to PostgreSQL should use an explicit TLS mode rather than relying on defaults. Ask your team which mode the database accepts and which CA certificate Zitadel trusts. Use verify-full where the database offers a certificate that matches its hostname, and avoid disable on any network that carries real data.
Limit access to the administrative console
The console is where administrators manage instances, organizations and policies, so it should not be open to the whole internet by default. Restrict the admin paths at the proxy by source network or VPN, require strong authentication for administrator accounts, and review who holds instance-level roles. Confirm these rules with a test from an unapproved network before go-live.
Pin, patch and back up together
Pin the Zitadel, login and PostgreSQL images to specific tags instead of floating latest tags, and schedule reviews of the release notes for each update. Back up the database and the masterkey together, because a database backup without the matching key cannot decrypt stored secrets. Test a restore on a separate host before relying on the procedure.
When a Compose deployment should graduate to Kubernetes
The main reason to leave Docker Compose for Kubernetes is high availability that has to survive a host failure. A single Compose host runs the Zitadel API, the Login container and PostgreSQL on one machine, so a server crash, a failed disk or a kernel patch that needs a reboot takes the whole identity layer down. If your service level expectations for sign-in cannot tolerate that outage window, or if your risk register already lists the single host as a dependency for every application that uses Zitadel, plan the move. Zitadel's self-hosting documentation, linked from this section's sibling pages, recommends a Kubernetes cluster with the official Helm chart for high availability, and that recommendation is the starting point for the design conversation. Ask your team to write down the availability target in its own words before choosing a platform, because the target decides how many nodes, zones and database replicas you need.
Other signals are operational. Move when you need rolling upgrades without downtime, where new API and Login pods come up before old ones drain, or when you need the API and the Login component to scale on different curves. Login traffic follows end users at peak hours, while API traffic follows machine clients, provisioning jobs and application back ends, so one Compose service cannot be sized for both. Also move when a second region, a second data center or a separate staging cluster needs the same manifests, or when your platform team already runs Kubernetes with monitoring, backup and admission controls that a Compose host would have to duplicate. Confirm which of these you actually need. If none applies, a well-run Compose deployment with a tested backup and restore is a reasonable production choice for a small tenant base.
Treat the move as a planned migration, not a file copy. The masterkey, the database and the external domain settings carry across, but the Kubernetes deployment needs its own TLS termination, ingress or Gateway API routing, separate init and setup steps, and a database that is not a bundled container. Schedule a rehearsal against a restored copy of the PostgreSQL data, check that the masterkey in the Kubernetes secret matches the one that encrypted the data, and confirm that every application's redirect URIs and issuer URL still resolve. Ask whoever will own the cluster to review the Helm values before cutover, and keep the Compose stack available for rollback until the new environment has passed your verification steps.
Limits to confirm in your environment
A Compose stack pins a small number of versions and behaviors that are easy to assume and costly to get wrong. The cards below list the items to confirm against vendor documentation or your own tests before you commit to a layout. Each one changes the file you write or the runbook you hand to operations.
Compose version and image tags
Confirm which Docker Compose version your hosts run and which Zitadel image tag matches the release you plan to deploy. Pin exact tags in the file rather than floating ones, and check the release notes for the target version before the first zitadel setup run. Record the tag in your change log so every later upgrade starts from a known state.
PostgreSQL version in the image
Zitadel supports PostgreSQL 14 through 18. Confirm that the database image tag you pin falls inside that range and that your team can support it for the life of the deployment. Check the database documentation for any version-specific setup, and plan a tested major upgrade path before you adopt a newer PostgreSQL release.
- Supported PostgreSQL
- 14 to 18
HTTP/2 and h2c for the API
Confirm whether the Zitadel API and gRPC traffic needs HTTP/2 or h2c between your proxy and the container. Test a login and a token request through the exact proxy you plan to run, not only through a direct port. A proxy that downgrades the upstream protocol can break clients in ways that look like login failures.
Self-hosting overviewMasterkey loss behavior
The masterkey encrypts secrets at rest. Confirm with the vendor documentation what happens to encrypted data if the key is lost or replaced, and whether it can be changed in place. Store a verified copy in a secrets manager, restrict who can read it, and rehearse restoring a backup with that copy before go-live.
Resource needs for your user count
Size the host, CPU, memory and database capacity against your expected daily active users, not against a generic example. Zitadel Cloud pricing uses daily active users as its unit, so use the same measure in your own capacity plan. Run a load test on a staging copy and watch database connections and response times before you set limits.
- DAU on Pro plan
- 25,000
Questions buyers ask about Compose deployments
How much does a Docker Compose deployment of Zitadel cost?
The software is free to run, so the cost is labor and infrastructure. Self-hosted Zitadel is licensed under AGPL 3.0 for the core, Console and hosted login, so there is no license fee for running it yourself. The recurring costs are the servers or virtual machines, the PostgreSQL service, backups, TLS certificates and the staff who patch and upgrade the stack. The one-time cost is design and setup: the proxy, secrets, domains and first configuration. A quote should split these into a fixed setup fee for the agreed scope and any retainer for upgrades or support, and should state who pays for each item. Ask for the cost of your own team's time separately so you can compare the two options fairly.
How long does setup and hardening take for a Compose stack?
Duration depends on how much of the stack is new to your organization and how many decisions are still open. A basic staging instance with a supplied domain, a proxy and a PostgreSQL service is the quickest path. Production hardening adds TLS in front of the proxy, a managed or separately backed-up database, secret handling for the masterkey, backup and restore testing, monitoring and an upgrade procedure. Each of these tends to lengthen the schedule, especially identity provider integrations and the approval steps for domains and certificates. Ask any partner for a written timeline tied to the agreed scope, with the assumptions about your environment listed, and confirm the start dependencies such as access to DNS and hosts.
What does the client team need to provide for the work?
The client side usually supplies hosts or cloud accounts, network access, DNS control for the public domain, TLS certificate issuance or a certificate authority process, and a place to store the masterkey. It also needs a named owner for identity decisions, such as which applications sign in first and which identity providers are connected. Security and compliance staff should confirm logging, retention and access rules early so the design can meet them. If you plan to run the stack afterward, assign operators who can read logs, restore a backup and follow the upgrade steps. Confirm each item in writing before the work starts so that delays are not charged to the wrong party.
Can an internal team deploy Zitadel with Compose without a partner?
Yes, a team with container, PostgreSQL and reverse proxy experience can deploy Zitadel with Compose using the official documentation. The harder parts are rarely the first start. They are the masterkey lifecycle, correct external domain and TLS settings, backups that have been restored in a test, and a repeatable upgrade. Zitadel publishes self-hosting guides for Linux, Docker Compose and Kubernetes, so the start is well documented. Consider a partner when the team lacks time to run the stack after launch, or when auditors will ask for evidence of hardening and tested recovery. Either way, check the documented steps against the release you intend to run, since the latest published release is the reference for new installs.
When does Docker Compose stop being enough for Zitadel?
Compose suits small production or staging use where one host, a single PostgreSQL service and a manual upgrade window are acceptable. It becomes a poor fit when you need high availability across several nodes, rolling upgrades without downtime, horizontal scaling of the API and login containers, or automated recovery after host failure. Zitadel's own self-hosting documentation recommends a Kubernetes cluster with the official Helm chart for high availability. Other signs include multiple teams deploying independently, strict change control that needs declarative deployment history, or a growing number of tenants that stresses the single host. Plan the migration path early so the masterkey, database and domain settings carry over without a reset.
What does AGPL licensing mean for a self-hosted Zitadel deployment?
Since Zitadel v3.0, released on 31 March 2025, the core, Console and hosted login are licensed under the GNU Affero General Public License 3.0, replacing Apache 2.0 for those components. The APIs, SDKs, proto definitions, examples, documentation, Helm charts and Terraform configurations remain under Apache 2.0. For an internal deployment, the AGPL terms matter most if you modify the core and make it available to users over a network, because the AGPL then requires you to offer the modified source to those users. Your legal team should review how your applications connect to Zitadel, since applications using the Apache 2.0 APIs and SDKs are licensed separately. Confirm the interpretation with counsel rather than relying on this summary.
What should a quote for a Compose deployment include?
A useful quote lists the scope in writing: the Zitadel release and version, the number of hosts, the proxy and TLS approach, the PostgreSQL arrangement, the masterkey storage method, backup and restore testing, monitoring, and the identity providers to connect. It should name the deliverables, such as configuration files, runbooks and a test report, and state what is excluded. Ask for the fee structure, the assumptions about your environment, the acceptance criteria and the handover steps. Also ask whether ongoing support or upgrades are priced separately as a retainer. DeployOpen works from a written scope and does not publish a price list, so the quote follows from the scope you agree.
Official Zitadel sources for self-hosting
Before you copy any Compose file into production, read the official self-hosting overview first. Zitadel documents self-hosting on Linux and macOS binaries, Docker Compose and Kubernetes, and the Compose path is one of three supported routes. The self-hosting overview shows how the API and Login components fit together, which environment variables and external domain settings apply, and which steps run during initialization and setup. Compare its service list with your own Compose file line by line, and confirm the image tags and startup order against the version you plan to deploy.
Next, check the database documentation before you size the PostgreSQL service. Self-hosted Zitadel uses PostgreSQL as its database, and the documentation lists the PostgreSQL versions it supports, which is 14 through 18 at the time of this writing. Confirm that the image tag you choose falls inside that range, and decide whether the database container will hold a persistent volume with backups, or whether an external PostgreSQL service will take over that role. The database documentation also covers the connection settings you will need for the masterkey and TLS work described elsewhere on this page.
Finally, read the GitHub releases page before every upgrade. Zitadel publishes each release with its changelog, and the latest release at the time of this writing is v4.19.5, dated 15 October 2026. Pin your Compose file to an explicit version, record the release notes you reviewed, and plan a test run against a staging copy of your data. The zitadel/zitadel releases page is the place to check for breaking changes that affect configuration or the database schema, so schedule that review as a standing step in your change process.
How DeployOpen scopes and delivers Zitadel on Compose
DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure, and that includes Zitadel on Docker Compose. Engagements are fixed-scope, so the scope, deliverables and timeline are agreed in writing before any work begins.
How we scope
- Confirm the target hostname, TLS approach and whether the deployment is staging or production.
- Record the PostgreSQL version and whether the database is hosted by your team or a managed service.
- Agree which login methods, identity providers and organizations the first release must support.
- Document where the masterkey will be stored and who may read it before installation starts.
How we build
- Assemble the Compose project with API, login, PostgreSQL and reverse proxy services in your environment.
- Configure external domains and proxy headers so instance routing and HTTP/2 behave as intended.
- Run setup and start phases in a controlled order, then verify health checks and admin console access.
- Test sign-in, token issuance and federation with a representative application before go-live.
How we hand over
- Deliver the Compose files, configuration files and environment templates under your version control.
- Provide a runbook covering start, stop, upgrade steps, masterkey custody and recovery from backup.
- Walk your operations and security staff through configuration decisions and the reasons behind them.
- Record the threshold at which you should move to Kubernetes, based on the scope agreed at the start.
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after the initial handover.
- Plan version upgrades against the release notes of the Zitadel version you run, with a tested rollback path.
- Include backup restore checks so recovery is proven, not assumed, before an incident occurs.
- Confirm retainer terms, response expectations and the upgrade cadence in the written agreement.

