You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -9,18 +9,15 @@ import PartialPodmanAlt from '@site/docs/_partial-podman-alt.mdx';
9
9
10
10
Running applications in Docker containers ensures consistent behavior across different systems and eliminates dependency conflicts.
11
11
12
-
You can use the Langflow Docker image to start a Langflow container.
13
-
14
-
This guide demonstrates several ways to deploy Langflow with [Docker](https://docs.docker.com/) and [Docker Compose](https://docs.docker.com/compose/):
12
+
This guide demonstrates several ways to run Langflow with [Docker](https://docs.docker.com/) and [Docker Compose](https://docs.docker.com/compose/):
15
13
16
14
*[Quickstart](#quickstart): Start a Langflow container with default values.
17
-
*[Use Docker Compose](#clone): Clone the Langflow repo, and then use Docker Compose to build the Langflow Docker container.
18
-
This option provides more control over the configuration, including a persistent PostgreSQL database service, while still using the base Langflow Docker image.
19
-
*[Create a custom flow image](#package-your-flow-as-a-docker-image): Use a Dockerfile to package a flow as a Docker image.
20
-
*[Create a custom Langflow image](#customize-the-langflow-docker-image): Use a Dockerfile to package a custom Langflow Docker image that includes your own code, custom dependencies, or other modifications.
21
-
*[Upgrade the Langflow Docker image](#upgrade-the-langflow-docker-image): Upgrade to a newer image without losing your database or flows by using persistent volumes and replacing only the container.
15
+
*[Use Docker Compose](#docker-compose): Run Langflow with a persistent PostgreSQL database and configurable environment variables.
16
+
*[Customize the Docker image](#customize): Package a flow or add your own code into a custom image built on top of the official Langflow image.
17
+
*[Build and run the Docker image from source](#build-from-source): Build a Docker image from a local clone of the repo, or start a full development environment with hot reload on both frontend and backend.
18
+
*[Upgrade the Langflow Docker image](#upgrade-the-langflow-docker-image): Upgrade to a newer image without losing your database or flows.
22
19
23
-
## Quickstart: Start a Langflow container with default values{#quickstart}
20
+
## Quickstart {#quickstart}
24
21
25
22
With Docker installed and running on your system, run the following command:
26
23
@@ -31,19 +28,13 @@ docker run -p 7860:7860 langflowai/langflow:latest
31
28
Then, access Langflow at `http://localhost:7860/`.
32
29
33
30
This container runs a pre-built Docker image with default settings.
34
-
For more control over the configuration, see [Clone the repo and run the Langflow Docker container](#clone).
35
-
36
-
## Clone the repo and run the Langflow Docker container {#clone}
37
-
38
-
Cloning the Langflow repository and using Docker Compose gives you more control over your configuration, allowing you to customize environment variables, use a persistent PostgreSQL database service (instead of the default SQLite database), and include custom dependencies.
31
+
For more control over the configuration, see [Use Docker Compose](#docker-compose).
39
32
40
-
The default deployment with Docker Compose includes the following:
33
+
## Use Docker Compose {#docker-compose}
41
34
42
-
-**Langflow service**: Runs the latest Langflow image with PostgreSQL as the database.
43
-
-**PostgreSQL service**: Provides persistent data storage for flows, users, and settings.
44
-
-**Persistent volumes**: Ensures your data survives container restarts.
35
+
Docker Compose gives you more control over your configuration, such as setting environment variables, using a persistent PostgreSQL database instead of the default SQLite database, and including custom dependencies.
45
36
46
-
The complete Docker Compose configuration is available in `docker_example/docker-compose.yml`.
37
+
The Langflow repo includes a ready-to-use Compose file at `docker_example/docker-compose.yml` that pulls the latest Langflow image from Docker Hub and includes persistent volume storage with PostgreSQL.
47
38
48
39
1. Clone the Langflow repository:
49
40
@@ -65,11 +56,13 @@ The complete Docker Compose configuration is available in `docker_example/docker
65
56
66
57
4. Access Langflow at `http://localhost:7860/`.
67
58
68
-
###Customize your deployment
59
+
## Customize the Docker Compose file {#customize}
69
60
70
-
You can customize the Docker Compose configuration to fit your specific deployment.
61
+
Customize the Docker Compose file to fit your deployment's requirements.
71
62
72
-
For example, to configure the container's database credentials using a `.env` file, do the following:
63
+
### Include environment variables
64
+
65
+
Configure a container's database credentials using a `.env` file.
73
66
74
67
1. Create a `.env` file with your database credentials in the same directory as `docker-compose.yml`:
75
68
@@ -84,7 +77,7 @@ For example, to configure the container's database credentials using a `.env` fi
84
77
LANGFLOW_CONFIG_DIR=/app/langflow
85
78
```
86
79
87
-
2.Modify the `docker-compose.yml`file to reference the `.env` file for both the `langflow` and `postgres` services:
80
+
2.Edit `docker-compose.yml` to replace the hardcoded values with variable references for both the `langflow` and `postgres` services:
88
81
89
82
```yaml
90
83
services:
@@ -99,17 +92,16 @@ For example, to configure the container's database credentials using a `.env` fi
99
92
- POSTGRES_DB=${POSTGRES_DB}
100
93
```
101
94
102
-
For a complete list of available environment variables, see [Langflow environment variables](/environment-variables).
95
+
With variable references in place, Docker Compose reads the values from your `.env` file at startup.
103
96
104
-
For more customization options, see [Customize the Langflow Docker image with your own code](#customize-the-langflow-docker-image).
105
-
106
-
## Package your flow as a Docker image {#package-your-flow-as-a-docker-image}
97
+
For a complete list of available environment variables, see [Langflow environment variables](/environment-variables).
107
98
108
-
This section shows you how to create a Dockerfile that builds a Docker image containing your Langflow flow. This approach is useful when you want to distribute a specific flow as a standalone container or deploy it to environments like Kubernetes.
99
+
### Package a flow into the image
109
100
110
-
Unlike the previous sections that use pre-built images, this method builds a custom image with your flow embedded inside it.
101
+
Embed a flow JSON directly into a Docker image.
102
+
This is useful for distributing a specific flow as a standalone container or deploying it to environments like Kubernetes.
111
103
112
-
1. Create a project directory, and change directory into it.
104
+
1. Create a project directory and change into it:
113
105
114
106
```bash
115
107
mkdir langflow-custom && cd langflow-custom
@@ -125,7 +117,7 @@ Unlike the previous sections that use pre-built images, this method builds a cus
125
117
cp /path/to/your/flow.json .
126
118
```
127
119
128
-
3. Create a Dockerfile to build your custom image:
120
+
3. Create a `Dockerfile`:
129
121
130
122
```dockerfile
131
123
FROM langflowai/langflow:latest
@@ -134,86 +126,170 @@ Unlike the previous sections that use pre-built images, this method builds a cus
134
126
ENV LANGFLOW_LOAD_FLOWS_PATH=/app/flows
135
127
```
136
128
137
-
This Dockerfile uses the official Langflow image as the base, creates a directory for your flows, copies your JSON flow files into the directory, and sets the environment variable to tell Langflow where to find the flows.
138
-
139
-
4. Build and test your custom image:
129
+
4. Build, test, and optionally push your image:
140
130
141
131
```bash
142
132
docker build -t myuser/langflow-custom:1.0.0 .
143
133
docker run -p 7860:7860 myuser/langflow-custom:1.0.0
For Kubernetes deployment, see [Deploy the Langflow production environment on Kubernetes](/deployment-kubernetes-prod).
138
+
139
+
### Add custom code or dependencies
140
+
141
+
Patch custom code into the pre-built image's installation.
142
+
This is useful when you need to add custom Python packages, replace a built-in component, or make targeted changes without a [full source build](#build-from-source).
143
+
144
+
This example replaces the built-in **Message History** component, but the same pattern applies to any component or file.
145
+
146
+
1. Create a directory for your custom Langflow setup:
147
147
148
148
```bash
149
-
docker push myuser/langflow-custom:1.0.0
149
+
mkdir langflow-custom && cd langflow-custom
150
150
```
151
151
152
-
Your custom image now contains your flow and can be deployed anywhere Docker runs. For Kubernetes deployment, see [Deploy the Langflow production environment on Kubernetes](/deployment-kubernetes-prod).
152
+
2. Create the directory structure that mirrors the component path:
153
153
154
-
## Customize the Langflow Docker image with your own code {#customize-the-langflow-docker-image}
While the previous section showed how to package a flow with a Docker image, this section shows how to customize the Langflow application itself. This is useful when you need to add custom Python packages or dependencies, modify Langflow's configuration or settings, include custom components or tools, or add your own code to extend Langflow's functionality.
158
+
3. Place your modified `memory.py` file in that directory.
157
159
158
-
This example demonstrates how to customize the **Message History** component, but the same approach can be used for any code modifications.
## Build and run the Docker image from source {#build-from-source}
182
192
183
-
# Expose the default Langflow port
184
-
EXPOSE 7860
193
+
:::tip
194
+
Both `make docker_build` and `make lfx_docker_build` use Podman by default. If you have Docker installed instead, pass the alias `DOCKER=docker` on the command line:
1. Create a directory for your custom Langflow setup:
202
+
If you've cloned the Langflow repository and want to build and run your local changes inside a Docker container, run:
193
203
194
-
```bash
195
-
mkdir langflow-custom &&cd langflow-custom
204
+
```shell
205
+
make docker_build
196
206
```
197
207
198
-
2. Create the necessary directory structure for your custom code.
199
-
In this example, Langflow expects `memory.py` to exist in the `/helpers` directory, so you create a directory in that location.
208
+
This builds `docker/build_and_push.Dockerfile` and tags the result `langflow:<version>`.
200
209
201
-
```bash
202
-
mkdir -p src/lfx/src/lfx/components/helpers
210
+
To run the image after building, run:
211
+
212
+
```shell
213
+
docker run -p 7860:7860 langflow:<version>
214
+
```
215
+
216
+
Replace `<version>` with the version in `pyproject.toml` at the repo root.
217
+
218
+
To build only the LFX executor CLI image instead of the full Langflow application, run:
219
+
220
+
```shell
221
+
make lfx_docker_build
222
+
```
223
+
224
+
This builds `src/lfx/docker/Dockerfile` and tags the result `lfx:latest`.
225
+
It produces a lightweight Alpine-based image that contains only the `lfx` CLI tool, with no frontend or Langflow UI.
226
+
227
+
The build context is the repo root, not `src/lfx/`. The Dockerfile copies from `pyproject.toml`, `uv.lock`, `src/lfx/`, and `src/sdk/`, so the full workspace is sent to the daemon. A root `.dockerignore` file partially mitigates this, but the first build will be slower than you might expect for a small CLI image.
228
+
229
+
### Write a custom source-based Dockerfile
230
+
231
+
When writing a source-based Dockerfile, you must copy the manifest files (`pyproject.toml`, `README.md`, and `uv.lock` where present) for the workspace members that `uv sync` needs to resolve dependencies before source is available.
232
+
The workspace members are defined in `[tool.uv.workspace]` in the root `pyproject.toml`.
233
+
You do not need to copy manifests for members like `src/langflow-stepflow` that are not required for the initial dependency-only sync.
234
+
The full source is copied later with `COPY ./src`, which brings those omitted members into the image before the second `uv sync`.
235
+
236
+
1. To copy all manifest files to your Dockerfile, include the following:
3. Place your modified `memory.py` file in the `/helpers` directory.
251
+
2. To install dependencies and copy the source, include the following:
206
252
207
-
4. Create a new file named `Dockerfile` in your `langflow-custom` directory, and then copy the Dockerfile contents shown above into it.
253
+
```dockerfile
254
+
RUN --mount=type=cache,target=/root/.cache/uv \
255
+
uv sync --frozen --no-install-project --no-editable --extra postgresql --no-group dev
208
256
209
-
5. Build and run the image:
257
+
COPY ./src /app/src
210
258
211
-
```bash
212
-
docker build -t myuser/langflow-custom:1.0.0 .
213
-
docker run -p 7860:7860 myuser/langflow-custom:1.0.0
259
+
RUN --mount=type=cache,target=/root/.cache/uv \
260
+
uv sync --frozen --no-editable --extra postgresql --no-group dev
214
261
```
215
262
216
-
This approach can be adapted for any other components or custom code you want to add to Langflow by modifying the file paths and component names.
263
+
The first `uv sync` installs only dependencies before the source is copied, so that Docker can cache that layer. The second `uv sync` installs the project packages (`langflow`, `lfx`) from the copied source. Both calls are required. Omitting the second will produce a container with all dependencies present but the project packages missing, which fails at runtime.
264
+
265
+
For an example, see [`docker/build_and_push_with_extras.Dockerfile`](https://github.com/langflow-ai/langflow/blob/main/docker/build_and_push_with_extras.Dockerfile).
266
+
267
+
### Start a development environment with `make dcdev_up`
268
+
269
+
`make dcdev_up`starts a full development environment from source using [`docker/dev.docker-compose.yml`](https://github.com/langflow-ai/langflow/blob/main/docker/dev.docker-compose.yml).
270
+
This is useful if you want to work on the Langflow codebase within a container.
271
+
272
+
To build the Langflow dcdev image, run:
273
+
274
+
```shell
275
+
make dcdev_up
276
+
```
277
+
278
+
Access the backend and Langflow UI at `http://localhost:7860/`.
279
+
Access the frontend dev server at `http://localhost:3000/`.
280
+
281
+
The following environment variables are set by default:
| `LANGFLOW_CONFIG_DIR` | `/var/lib/langflow` | Directory for Langflow config and data |
289
+
290
+
To override these values, edit `docker/dev.docker-compose.yml` directly.
291
+
292
+
`docker/dev.docker-compose.yml`uses literal values in its `environment:` block, such as `- LANGFLOW_SUPERUSER=langflow`. Docker Compose v2 gives `environment:` block literal values higher precedence than shell-exported variables and `env_file:`, so neither `export LANGFLOW_SUPERUSER=myadmin` or a `.env` file will override them. Edit the file directly instead.
217
293
218
294
## Upgrade the Langflow Docker image {#upgrade-the-langflow-docker-image}
219
295
@@ -226,7 +302,7 @@ For example, this Docker Compose file uses a bind mount for Langflow data (`./la
226
302
```yaml
227
303
services:
228
304
langflow:
229
-
image: langflowai/langflow:1.8.0
305
+
image: langflowai/langflow:1.11.0
230
306
environment:
231
307
- LANGFLOW_CONFIG_DIR=/app/langflow
232
308
volumes:
@@ -243,11 +319,11 @@ For example, this Docker Compose file uses a bind mount for Langflow data (`./la
243
319
langflow-postgres:
244
320
```
245
321
246
-
For additional examples, see the [Docker Compose configuration](#clone) and the [docker_example compose file](https://github.com/langflow-ai/langflow/blob/main/docker_example/docker-compose.yml).
322
+
For additional examples, see the [Docker Compose configuration](#docker-compose) and the [docker_example compose file](https://github.com/langflow-ai/langflow/blob/main/docker_example/docker-compose.yml).
247
323
248
324
2. Pull the new image and update the image tag in your `docker-compose.yml` or `docker run` command.
249
325
250
-
With Docker Compose, set the image in your compose file, such as `image: langflowai/langflow:1.8.0`, and then pull:
326
+
With Docker Compose, set the image in your compose file, such as `image: langflowai/langflow:1.11.0`, and then pull:
251
327
252
328
```bash
253
329
docker compose pull
@@ -256,7 +332,7 @@ For example, this Docker Compose file uses a bind mount for Langflow data (`./la
256
332
With `docker run`, pull the image:
257
333
258
334
```bash
259
-
docker pull langflowai/langflow:1.8.0
335
+
docker pull langflowai/langflow:1.11.0
260
336
```
261
337
262
338
3. Restart the container. The same volumes will be reattached, so your database and flows are preserved.
@@ -270,12 +346,12 @@ For example, this Docker Compose file uses a bind mount for Langflow data (`./la
270
346
With `docker run`, use the same volume mount and the new image tag:
271
347
272
348
```bash
273
-
docker run -p 7860:7860 -v langflow-data:/app/langflow langflowai/langflow:1.8.0
349
+
docker run -p 7860:7860 -v langflow-data:/app/langflow langflowai/langflow:1.11.0
274
350
```
275
351
276
352
This approach keeps the persistent volumes separate from the Langflow container, so you can upgrade the Langflow application without losing data.
277
353
278
354
If you need to upgrade to a custom image based on a Langflow release, such as to add `uv` in `1.8.0`, first build a derived image from the official image, and then follow the same steps above.
279
355
Set the custom image in your compose file or `docker run`, and then pull and restart.
280
356
281
-
For a minimal Dockerfile that adds `uv` to the 1.8.0 image, see the [release notes](/release-notes) (“Docker image no longer includes uv or uvx”).
357
+
For a minimal Dockerfile that adds `uv` to the 1.8.0 image, see the [release notes](/release-notes) ("Docker image no longer includes uv or uvx").
0 commit comments