Skip to main content
Account
Lesson 3 of 9

How to Install Zitadel with Docker Compose (Step-by-Step)

Run Zitadel locally with Docker Compose and Postgres: health checks, master key, TLS for dev, and the console on localhost:8080.

How to Install Zitadel with Docker Compose (Step-by-Step)

Local development setup

Learn how to build a local development setup for Zitadel with Docker Compose without breaking your quickstart with race conditions. This hands-on tutorial covers extending your Docker Compose file to run Zitadel alongside Postgres, handling service dependencies, configuring health checks, and avoiding common pitfalls. Includes master key setup, TLS configuration for development, and getting the Zitadel console running on localhost:8080. Follow along with the actual Zitadel documentation examples and learn why order matters in your compose files. Perfect for developers who want a working Zitadel setup fast without the headaches.

Transcript

Generated from English captions. Select a timestamp to jump to that moment.

0:00 David Flanagan: Welcome back to the Complete Guide to Zitadel. In this video, we're gonna take a look at extending our Docker Compose file to not only run Postgres, but now run Zitadel itself. Let's get started. So here we have the Docker Compose file we have from the prerequisite video. If you're going to run Zitadel side by side with Postgres via Docker Compose, we do need to expand this setup just a little bit. Why? Because we have dependencies. The moment we add a Zitadel container, we have a race condition between Zitadel trying to speak to Postgres and Postgres being healthy.

0:47 Fortunately for us, this is well documented by the Zitadel team. If we head over to the Zitadel website, you can select develop and documentation. We then go to search or press control K and say Deploy. On the left hand side, you'll see we have Docker Compose and we have an example docker-compose.yaml. Let's just copy all of this and we'll walk through it step by step to understand the changes required for this to work. So I have pasted this verbatim from the website if you want to get a copy of this. The link is in the description below.

1:32 Now I can be quite particular about the format and the ordering of my compose files. So the first thing I'm going to do is grab the networks and stick it at the top, and then grab our database and stick that as the first service. Now, why do I put networks at the top? I also do this for volumes because I feel that it makes sense to understand the prerequisites, the networks, and the volumes before we even start to discuss or talk about services. When you see a network defined like this, this just means use the defaults,

2:07 which we can also do with a tilda value, which I think is a bit cleaner in YAML because we have key value pairs, and this leaves a little bit up to imagination or understanding how YAML works. Next we have our database service. Again, I'm gonna call mine Postgres, so it's very clear what we are running. I always like to put the image that we're running first, and because we've already pulled image 17 as part of the prerequisites, we're gonna stick with this here, also using mirror.gcr.io/library/postgres. Now we can leave restart always here. That is perfectly fine in a development environment, and I

2:54 certainly hope you're not slinging this docker-compose to production. Hell mend you. Then we've got environment variables just like we had earlier. We have to specify the username and the password. These are slightly different keys, but Postgres is flexible in that it doesn't matter. So we'll leave this as is. We then say that we want Postgres as part of our Zitadel network. We defined as the top of the file. Now because in this series we're only really using Docker Compose as is development environment, the network is not that important. However, if you do go down a route of shipping this Docker Compose to

3:33 production, you might wanna make sure that your Postgres is on a backend network that is not publicly available and your Zitadel is able to bridge and communicate over both. Now to avoid the race condition where we're waiting for Zitadel to speak to Postgres and Postgres to be healthy, we can define a health check. Here we're saying we want to run a command inside of this container, and we're just using the pg_isready script with the credentials that we need to speak to the database or at least get a successful connection to the database. We'll run this every 10 seconds with a 30 second timeout.

4:11 We'll retry it five times and we're gonna give Postgres 20 seconds to be healthy. Now, I'll be honest, these are quite liberal values and I don't really feel we need them to be this big, especially in our development setup. Production is always different, so yeah, we can run the health check every 10 seconds. That's not going to scare or that's not gonna concern Postgres at all. If we need to wait more than one second for an isready check; I'd be surprised. We'll retry this five times and to be honest, we're gonna give it five seconds to get healthy.

4:48 Now we have Zitadel itself. We'll push the image to the top. We're using GHCR because Zitadel publishes all of their images to GitHub's Container Registry as part of their CI/CD workflow. You can use latest, but feel free to go and grab the latest version that you're comfortable with, or the one you plan on shipping to production. For this series, we'll be using v2.70.6. I am happy with the restart, always for local development. The network is fine. Now when running Zitadel locally or with Docker Compose you do need to provide your master key, which has to be a 32 character long string.

5:31 This is a master encryption key used to generate all other encryption keys, so when you move to production, you need to keep this value safe and secure, either encrypted via a KMS system or stored in your password manager of choice. Also for local development, we can disable TLS. Now don't worry about picking random strengths here and disabling TLS mode, because in the future video in the series, we're gonna take a look at the production deployment of Zitadel and we will cover all of these things to make sure your production deployment is plain sailing. All right, so back on our terminal, we run Docker Compose Up.

6:11 We can see is pulling the Zitadel image. That'll just take a moment. It's not very big. We can see Postgres has started, but Zitadel isn't doing anything yet, and that's because of the health checks that were added and the dependency constraint. And now that Postgres is ready, the health checks should be running. Any moment now, and Zitadel starts. Now. Zitadel is gonna have to create the database, run the migrations, which it is doing now. But if we head over to the browser, we can go to localhost:8080 and we have a UI console. If we pop back to the documentation and scroll down, you'll see that the default

6:54 username and password is available here. We pop in our username, enter the password. We can skip the two factor. We set a new password, making sure that they're the same, which is clearly a good saying when this is the hardest part. We head next, and there we are. We're now at the Zitadel Console. Simple. And that's all there is to run in Zitadel with Docker Compose. Join us for the next video where we take a look at setting up your first project. We'll see you soon.

Course curriculum (9 lessons)
  1. 01. Introduction
  2. 02. Prerequisites
  3. 03. How to Install Zitadel with Docker Compose (Step-by-Step)
  4. 04. Installing Zitadel on Kubernetes with Helm
  5. 05. Zitadel Cloud
  6. 06. Your First Application
  7. 07. Integrating with an Astro Application
  8. 08. Passwords, Passkeys, and MFA
  9. 09. Configuring OAuth Providers (Google, GitHub, etc.)

Loading optional course email signup. If it does not load, reload this lesson to retry. Signup requires JavaScript; all lesson content remains available without signing up.