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}
31
+
For more control over the configuration, see [Use Docker Compose](#docker-compose).
37
32
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.
33
+
## Use Docker Compose {#docker-compose}
39
34
40
-
The default deployment with Docker Compose includes the following:
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.
41
36
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.
45
-
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}
60
+
61
+
Customize the Docker Compose file to fit your deployment's requirements.
69
62
70
-
You can customize the Docker Compose configuration to fit your specific deployment.
63
+
### Include environment variables
71
64
72
-
For example, to configure the container's database credentials using a `.env` file, do the following:
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
@@ -101,15 +94,12 @@ For example, to configure the container's database credentials using a `.env` fi
101
94
102
95
For a complete list of available environment variables, see [Langflow environment variables](/environment-variables).
103
96
104
-
For more customization options, see [Customize the Langflow Docker image with your own code](#customize-the-langflow-docker-image).
97
+
### Package a flow into the image
105
98
106
-
## Package your flow as a Docker image {#package-your-flow-as-a-docker-image}
99
+
Embed a flow JSON directly into a Docker image.
100
+
This is useful for distributing a specific flow as a standalone container or deploying it to environments like Kubernetes.
107
101
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.
109
-
110
-
Unlike the previous sections that use pre-built images, this method builds a custom image with your flow embedded inside it.
111
-
112
-
1. Create a project directory, and change directory into it.
102
+
1. Create a project directory and change into it:
113
103
114
104
```bash
115
105
mkdir langflow-custom && cd langflow-custom
@@ -125,7 +115,7 @@ Unlike the previous sections that use pre-built images, this method builds a cus
125
115
cp /path/to/your/flow.json .
126
116
```
127
117
128
-
3. Create a Dockerfile to build your custom image:
118
+
3. Create a `Dockerfile`:
129
119
130
120
```dockerfile
131
121
FROM langflowai/langflow:latest
@@ -134,86 +124,151 @@ Unlike the previous sections that use pre-built images, this method builds a cus
134
124
ENV LANGFLOW_LOAD_FLOWS_PATH=/app/flows
135
125
```
136
126
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:
127
+
4. Build, test, and optionally push your image:
140
128
141
129
```bash
142
130
docker build -t myuser/langflow-custom:1.0.0 .
143
131
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).
136
+
137
+
### Add custom code or dependencies
138
+
139
+
Patch custom code into the pre-built image's installation.
140
+
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).
141
+
142
+
This example replaces the built-in **Message History** component, but the same pattern applies to any component or file.
143
+
144
+
1. Create a directory for your custom Langflow setup:
145
+
146
+
```bash
147
+
mkdir langflow-custom &&cd langflow-custom
144
148
```
145
149
146
-
5. Push your image to Docker Hub (optional):
150
+
2. Create the directory structure that mirrors the component path:
147
151
148
152
```bash
149
-
docker push myuser/langflow-custom:1.0.0
153
+
mkdir -p src/lfx/src/lfx/components/helpers
154
+
```
155
+
156
+
3. Place your modified `memory.py` file in that directory.
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).
181
+
5. Build and run the image:
153
182
154
-
## Customize the Langflow Docker image with your own code {#customize-the-langflow-docker-image}
183
+
```bash
184
+
docker build -t myuser/langflow-custom:1.0.0 .
185
+
docker run -p 7860:7860 myuser/langflow-custom:1.0.0
186
+
```
155
187
156
-
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.
157
188
158
-
This example demonstrates how to customize the **Message History** component, but the same approach can be used for any code modifications.
189
+
## Build and run the Docker image from source {#build-from-source}
159
190
160
-
```dockerfile
161
-
FROM langflowai/langflow:latest
191
+
If you've cloned the Langflow repository and want to build and run your local changes inside a Docker container, run:
This builds `src/lfx/docker/Dockerfile` and tags the result `lfx:latest`.
215
+
It produces a lightweight Alpine-based image that contains only the `lfx` CLI tool, with no frontend or Langflow UI.
191
216
192
-
1. Create a directory for your custom Langflow setup:
217
+
### Write a custom source-based Dockerfile
193
218
194
-
```bash
195
-
mkdir langflow-custom &&cd langflow-custom
219
+
When writing a source-based Dockerfile, you must copy the manifest files (`pyproject.toml`, `README.md`, and `uv.lock` where present) for every workspace member before running `uv sync`.
220
+
The workspace members are defined in `[tool.uv.workspace]` in the root `pyproject.toml`.
221
+
222
+
1. To copy all manifest files to your Dockerfile, include the following:
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.
237
+
2. To install dependencies and copy the source, include the following:
200
238
201
-
```bash
202
-
mkdir -p src/lfx/src/lfx/components/helpers
239
+
```dockerfile
240
+
RUN --mount=type=cache,target=/root/.cache/uv \
241
+
uv sync --frozen --no-install-project --no-editable --extra postgresql --no-group dev
242
+
243
+
COPY ./src /app/src
203
244
```
204
245
205
-
3. Place your modified `memory.py` file in the `/helpers` directory.
246
+
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).
206
247
207
-
4. Create a new file named `Dockerfile` in your `langflow-custom` directory, and then copy the Dockerfile contents shown above into it.
248
+
### Start a development environment with `make dcdev_up`
208
249
209
-
5. Build and run the image:
250
+
`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).
251
+
This is useful if you want to work on the Langflow codebase within a container.
210
252
211
-
```bash
212
-
docker build -t myuser/langflow-custom:1.0.0 .
213
-
docker run -p 7860:7860 myuser/langflow-custom:1.0.0
214
-
```
253
+
To build the Langflow dcdev image, run:
254
+
255
+
```shell
256
+
make dcdev_up
257
+
```
258
+
259
+
Access the backend and Langflow UI at `http://localhost:7860/`.
260
+
Access the frontend dev server at `http://localhost:3000/`.
261
+
262
+
The following environment variables are set by default:
|`LANGFLOW_CONFIG_DIR`|`/var/lib/langflow`| Directory for Langflow config and data |
215
270
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.
271
+
To override these values, create a `.env` file in the repo root before running `make dcdev_up`.
217
272
218
273
## Upgrade the Langflow Docker image {#upgrade-the-langflow-docker-image}
219
274
@@ -243,7 +298,7 @@ For example, this Docker Compose file uses a bind mount for Langflow data (`./la
243
298
langflow-postgres:
244
299
```
245
300
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).
301
+
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
302
248
303
2. Pull the new image and update the image tag in your `docker-compose.yml` or `docker run` command.
249
304
@@ -278,4 +333,4 @@ This approach keeps the persistent volumes separate from the Langflow container,
278
333
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
334
Set the custom image in your compose file or `docker run`, and then pull and restart.
280
335
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”).
336
+
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