-
Notifications
You must be signed in to change notification settings - Fork 17
Add Docker Compose support #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alexandreroman
wants to merge
1
commit into
temporalio:main
Choose a base branch
from
alexandreroman:feature/docker-compose-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+120
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| # Running Temporal with Docker Compose | ||
|
|
||
| ## Overview | ||
|
|
||
| Docker Compose provides a convenient way to run a Temporal development environment as a set of containers. This is an alternative to installing the Temporal CLI locally and running `temporal server start-dev`. | ||
|
|
||
| All examples in this guide work with both **Docker Compose** and **Podman Compose**. Simply replace `docker compose` with `podman compose` in all commands. The `compose.yaml` file format is the same for both runtimes. | ||
|
|
||
| This approach is especially useful when: | ||
|
|
||
| - You want a reproducible, self-contained dev environment | ||
| - You are running multiple services (workers, frontends) that connect to Temporal | ||
| - You want to simulate a production-like setup locally | ||
|
|
||
| ## Minimal Compose File | ||
|
|
||
| A minimal `compose.yaml` to run Temporal for development: | ||
|
|
||
| ```yaml | ||
| services: | ||
| temporal: | ||
| image: temporalio/temporal | ||
| ports: | ||
| - "7233:7233" # gRPC frontend (used by workers and clients) | ||
| - "8233:8233" # Dev Server web UI | ||
| command: server start-dev --ip 0.0.0.0 | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "temporal operator cluster health"] | ||
| interval: 10s | ||
| timeout: 10s | ||
| retries: 3 | ||
| ``` | ||
|
|
||
| Start it with: | ||
|
|
||
| ```bash | ||
| docker compose up -d | ||
| # or with Podman: | ||
| podman compose up -d | ||
| ``` | ||
|
|
||
| The Temporal Web UI is then available at `http://localhost:8233`. | ||
|
|
||
| ## Key Ports | ||
|
|
||
| | Port | Protocol | Purpose | | ||
| |------|----------|---------| | ||
| | 7233 | gRPC | Frontend service — workers and clients connect here | | ||
| | 8233 | HTTP | Dev Server web UI for inspecting workflows | | ||
|
|
||
| ## Connecting Workers to Temporal in Docker Compose | ||
|
|
||
| Workers running as containers in the same Compose network connect to `temporal:7233` (using the service name as hostname). Workers running on the host machine connect to `localhost:7233`. | ||
|
|
||
| ### Worker as a Compose Service | ||
|
|
||
| ```yaml | ||
| services: | ||
| temporal: | ||
| image: temporalio/temporal | ||
| ports: | ||
| - "7233:7233" | ||
| - "8233:8233" | ||
| command: server start-dev --ip 0.0.0.0 | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "temporal operator cluster health"] | ||
| interval: 10s | ||
| timeout: 10s | ||
| retries: 3 | ||
|
|
||
| worker: | ||
| build: | ||
| context: ./worker | ||
| environment: | ||
| - TEMPORAL_ADDRESS=temporal:7233 | ||
| restart: on-failure | ||
| depends_on: | ||
| temporal: | ||
| condition: service_healthy | ||
| ``` | ||
|
|
||
| Important points: | ||
|
|
||
| - **`depends_on` with `service_healthy`** ensures the worker does not start until Temporal is ready to accept connections. Without this, the worker will crash-loop on startup. | ||
| - **`restart: on-failure`** lets the worker recover from transient errors. | ||
| - **`TEMPORAL_ADDRESS`** is the standard environment variable used by Temporal SDKs and CLI to locate the Temporal frontend service. | ||
|
|
||
| ## Using Podman Instead of Docker | ||
|
|
||
| Podman is a daemonless, rootless container engine that is a drop-in replacement for Docker. Podman Compose reads the same `compose.yaml` format. | ||
|
|
||
| ### Usage | ||
|
|
||
| Replace `docker compose` with `podman compose` in all commands: | ||
|
|
||
| ```bash | ||
| podman compose up -d # Start all services | ||
| podman compose down # Stop and remove all services | ||
| podman compose logs -f worker # Follow worker logs | ||
| podman compose ps # List running services | ||
| ``` | ||
|
|
||
| ### Podman-Specific Notes | ||
|
|
||
| - **Rootless networking**: Podman runs rootless by default. Containers in the same Compose project share a network and can reach each other by service name, just like Docker. | ||
| - **`podman-compose` vs `docker compose`**: `podman-compose` is a standalone Python tool. Alternatively, if `podman` is aliased to `docker`, the `docker compose` CLI plugin also works with Podman. | ||
| - **Healthchecks**: Podman supports healthchecks and `depends_on: condition: service_healthy` the same way as Docker Compose. | ||
| - **Build support**: `podman compose build` uses Buildah under the hood. Dockerfiles work without modification. | ||
|
|
||
| ## Tips | ||
|
|
||
| - **Always use the healthcheck** on the Temporal service and `depends_on: condition: service_healthy` on workers. Without this, workers will fail to connect on startup. | ||
| - **Use `--ip 0.0.0.0`** in the Temporal dev server command so it listens on all interfaces, not just localhost. This is required for other containers to connect. | ||
| - **The `temporalio/temporal` image** bundles the Temporal CLI and runs the dev server. It is meant for development, not production. For production self-hosted deployments, use the `temporalio/auto-setup` image with a real database (PostgreSQL or MySQL). | ||
| - **Namespace creation**: The dev server creates a `default` namespace automatically. For custom namespaces, use `temporal operator namespace create` after the server is healthy. | ||
| - **Data persistence**: By default the dev server stores data in memory. Data is lost when the container is recreated. To persist data across restarts, mount a volume for the database file or use a dedicated database service. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide guidance at this point for when the model should / shouldn't use Docker. You already have the content for that elsewhere (
You want a reproducible, self-contained...), just move it up here so the model sees that before deciding to load docker-compose.md.Also, please do keep the guidance as pushing non-docker as the "default" for now.