refactor the content (#586)

Co-authored-by: Riskey <riskey47@dify.ai>
This commit is contained in:
Riskey
2025-12-05 23:46:18 +08:00
committed by GitHub
parent a309694a4a
commit 153334c004

View File

@@ -1,151 +1,121 @@
---
title: Docker Compose
title: Deploy Dify with Docker Compose
sidebarTitle: Docker Compose
---
<Tip>
For common deployment questions, see [FAQs](/en/self-host/quick-start/faqs).
</Tip>
## Prerequisites
## Before Deployment
> Before installing Dify, make sure your machine meets the following minimum system requirements:
>
> * CPU >= 2 Core
> * RAM >= 4 GiB
Make sure your machine meets the following minimum system requirements.
<table>
<thead>
<tr>
<th>Operating System</th>
<th>Software</th>
<th>Explanation</th>
</tr>
</thead>
<tbody>
<tr>
<td>macOS 10.14 or later</td>
<td>Docker Desktop</td>
<td>Set the Docker virtual machine (VM) to use a minimum of 2 virtual CPUs (vCPUs) and 8 GB of initial memory. Otherwise, the installation may fail. For more information, please refer to the <a href="https://docs.docker.com/desktop/mac/install/">Docker Desktop installation guide for Mac</a>.</td>
</tr>
<tr>
<td>Linux platforms</td>
<td>
<p>Docker 19.03 or later</p>
<p>Docker Compose 1.28 or later</p>
</td>
<td>Please refer to the <a href="https://docs.docker.com/engine/install/">Docker installation guide</a> and <a href="https://docs.docker.com/compose/install/">the Docker Compose installation guide</a> for more information on how to install Docker and Docker Compose, respectively.</td>
</tr>
<tr>
<td>Windows with WSL 2 enabled</td>
<td>Docker Desktop</td>
<td>We recommend storing the source code and other data that is bound to Linux containers in the Linux file system rather than the Windows file system. For more information, please refer to the <a href="https://docs.docker.com/desktop/windows/install/#wsl-2-backend">Docker Desktop installation guide for using the WSL 2 backend on Windows.</a></td>
</tr>
</tbody>
</table>
### Hardware
## Clone Dify
- CPU >= 2 Core
- RAM >= 4 GiB
Clone the Dify source code to your local machine:
### Software
```bash
git clone --branch "$(curl -s https://api.github.com/repos/langgenius/dify/releases/latest | jq -r .tag_name)" https://github.com/langgenius/dify.git
```
| Operating System | Required Software | Notes |
| :----------------------------- | :---------------------------------------- | :----- |
| macOS 10.14 or later | Docker Desktop | Configure the Docker virtual machine with at least 2 virtual CPUs and 8 GiB of memory. <br></br><br></br>For installation instructions, see [Install Docker Desktop on Mac](https://docs.docker.com/desktop/mac/install/). |
| Linux distributions | Docker 19.03+<br></br><br></br>Docker Compose 1.28+ | For installation instructions, see [Install Docker Engine](https://docs.docker.com/engine/install/) and [Install Docker Compose](https://docs.docker.com/compose/install/). |
| Windows with WSL 2 enabled | Docker Desktop | Store source code and data bound to Linux containers in the Linux file system rather than Windows. <br></br><br></br>For installation instructions, see [Install Docker Desktop on Windows](https://docs.docker.com/desktop/windows/install/#wsl-2-backend). |
## Start Dify
1. Navigate to the Docker directory in the Dify source code
## Deploy and Start Dify
<Steps>
<Step title="Clone Dify">
Clone the Dify source code to your local machine.
```bash
git clone --branch "$(curl -s https://api.github.com/repos/langgenius/dify/releases/latest | jq -r .tag_name)" https://github.com/langgenius/dify.git
```
</Step>
<Step title="Start Dify">
1. Navigate to the `docker` directory in the Dify source code:
```bash
cd dify/docker
```
2. Copy the environment configuration file
2. Copy the example environment configuration file:
```bash
cp .env.example .env
```
3. Update directory ownership on the host
```bash
sudo chown -R 1001:1001 ./volumes/app/storage
```
4. Start the Docker containers
Choose the appropriate command to start the containers based on the Docker Compose version on your system. You can use the `docker compose version` command to check the version, and refer to the [Docker documentation](https://docs.docker.com/compose/install/) for more information:
* If you have Docker Compose V2, use the following command:
```bash
docker compose up -d
cp .env.example .env
```
* If you have Docker Compose V1, use the following command:
3. Start the containers using the command that matches your Docker Compose version:
```bash
docker-compose up -d
```
<Tip>
Run `docker compose version` to check your Docker Compose version.
</Tip>
After executing the command, you should see output similar to the following, showing the status and start time of all containers:
<CodeGroup>
```bash Docker Compose V2
docker compose up -d
```
```bash Docker Compose V1
docker-compose up -d
```
</CodeGroup>
```bash
[+] Running 13/13
✔ Network docker_ssrf_proxy_network Created 10.0s
✔ Network docker_default Created 0.1s
✔ Container docker-sandbox-1 Started 0.3s
✔ Container docker-db_postgres-1 Healthy 2.8s
✔ Container docker-web-1 Started 0.3s
✔ Container docker-redis-1 Started 0.3s
✔ Container docker-ssrf_proxy-1 Started 0.4s
✔ Container docker-weaviate-1 Started 0.3s
✔ Container docker-worker_beat-1 Started 3.2s
✔ Container docker-api-1 Started 3.2s
✔ Container docker-worker-1 Started 3.2s
✔ Container docker-plugin_daemon-1 Started 3.2s
✔ Container docker-nginx-1 Started 3.4s
```
The following containers will be started:
5. Check if all containers are running successfully
- 5 core services: `api`, `worker`, `worker_beat`, `web`, `plugin_daemon`
- 6 dependent components: `weaviate`, `db_postgres`, `redis`, `nginx`, `ssrf_proxy`, `sandbox`
```bash
docker compose ps
```
You should see output similar to the following, showing the status and start time of each container:
This includes 5 core services: `api / worker / worker_beat / web / plugin_daemon`, and 6 dependent components: `weaviate / db_postgres / redis / nginx / ssrf_proxy / sandbox` .
```bash
[+] Running 13/13
✔ Network docker_ssrf_proxy_network Created 10.0s
✔ Network docker_default Created 0.1s
✔ Container docker-sandbox-1 Started 0.3s
✔ Container docker-db_postgres-1 Healthy 2.8s
✔ Container docker-web-1 Started 0.3s
✔ Container docker-redis-1 Started 0.3s
✔ Container docker-ssrf_proxy-1 Started 0.4s
✔ Container docker-weaviate-1 Started 0.3s
✔ Container docker-worker_beat-1 Started 3.2s
✔ Container docker-api-1 Started 3.2s
✔ Container docker-worker-1 Started 3.2s
✔ Container docker-plugin_daemon-1 Started 3.2s
✔ Container docker-nginx-1 Started 3.4s
```
4. Verify that all containers are running successfully:
```bash
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
docker-api-1 langgenius/dify-api:1.10.1 "/bin/bash /entrypoi…" api 26 seconds ago Up 22 seconds 5001/tcp
docker-db_postgres-1 postgres:15-alpine "docker-entrypoint.s…" db_postgres 26 seconds ago Up 25 seconds (healthy) 5432/tcp
docker-nginx-1 nginx:latest "sh -c 'cp /docker-e…" nginx 26 seconds ago Up 22 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp
docker-plugin_daemon-1 langgenius/dify-plugin-daemon:0.4.1-local "/bin/bash -c /app/e…" plugin_daemon 26 seconds ago Up 22 seconds 0.0.0.0:5003->5003/tcp, :::5003->5003/tcp
docker-redis-1 redis:6-alpine "docker-entrypoint.s…" redis 26 seconds ago Up 25 seconds (health: starting) 6379/tcp
docker-sandbox-1 langgenius/dify-sandbox:0.2.12 "/main" sandbox 26 seconds ago Up 25 seconds (health: starting)
docker-ssrf_proxy-1 ubuntu/squid:latest "sh -c 'cp /docker-e…" ssrf_proxy 26 seconds ago Up 25 seconds 3128/tcp
docker-weaviate-1 semitechnologies/weaviate:1.27.0 "/bin/weaviate --hos…" weaviate 26 seconds ago Up 25 seconds
docker-web-1 langgenius/dify-web:1.10.1 "/bin/sh ./entrypoin…" web 26 seconds ago Up 25 seconds 3000/tcp
docker-worker-1 langgenius/dify-api:1.10.1 "/bin/bash /entrypoi…" worker 26 seconds ago Up 22 seconds 5001/tcp
docker-worker_beat-1 langgenius/dify-api:1.10.1 "/bin/bash /entrypoi…" worker_beat 26 seconds ago Up 22 seconds 5001/tcp
```
```bash
docker compose ps
```
With these steps, you should be able to install Dify successfully.
You should see output similar to the following, with each container in the `Up` or `healthy` status:
## Upgrade Dify
Enter the docker directory of the dify source code and execute the following commands:
```bash
cd dify/docker
docker compose down
git pull origin main
docker compose pull
docker compose up -d
```
<Note>
* If the `.env.example` file has been updated, be sure to modify your local `.env` file accordingly.
* Check and modify the configuration items in the `.env` file as needed to ensure they match your actual environment. You may need to add any new variables from `.env.example` to your `.env` file, and update any values that have changed.
</Note>
```bash
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
docker-api-1 langgenius/dify-api:1.10.1 "/bin/bash /entrypoi…" api 26 seconds ago Up 22 seconds 5001/tcp
docker-db_postgres-1 postgres:15-alpine "docker-entrypoint.s…" db_postgres 26 seconds ago Up 25 seconds (healthy) 5432/tcp
docker-nginx-1 nginx:latest "sh -c 'cp /docker-e…" nginx 26 seconds ago Up 22 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp
docker-plugin_daemon-1 langgenius/dify-plugin-daemon:0.4.1-local "/bin/bash -c /app/e…" plugin_daemon 26 seconds ago Up 22 seconds 0.0.0.0:5003->5003/tcp, :::5003->5003/tcp
docker-redis-1 redis:6-alpine "docker-entrypoint.s…" redis 26 seconds ago Up 25 seconds (health: starting) 6379/tcp
docker-sandbox-1 langgenius/dify-sandbox:0.2.12 "/main" sandbox 26 seconds ago Up 25 seconds (health: starting)
docker-ssrf_proxy-1 ubuntu/squid:latest "sh -c 'cp /docker-e…" ssrf_proxy 26 seconds ago Up 25 seconds 3128/tcp
docker-weaviate-1 semitechnologies/weaviate:1.27.0 "/bin/weaviate --hos…" weaviate 26 seconds ago Up 25 seconds
docker-web-1 langgenius/dify-web:1.10.1 "/bin/sh ./entrypoin…" web 26 seconds ago Up 25 seconds 3000/tcp
docker-worker-1 langgenius/dify-api:1.10.1 "/bin/bash /entrypoi…" worker 26 seconds ago Up 22 seconds 5001/tcp
docker-worker_beat-1 langgenius/dify-api:1.10.1 "/bin/bash /entrypoi…" worker_beat 26 seconds ago Up 22 seconds 5001/tcp
```
</Step>
</Steps>
## Access Dify
Access administrator initialization page to set up the admin account:
1. Open the administrator initialization page to set up the admin account:
```bash
# Local environment
@@ -155,11 +125,11 @@ http://localhost/install
http://your_server_ip/install
```
Dify web interface address:
2. After completing the admin account setup, log in to Dify at:
```bash
# Local environment
http://localhost
http://localhost
# Server environment
http://your_server_ip
@@ -167,7 +137,7 @@ http://your_server_ip
## Customize Dify
Edit the environment variable values in your `.env` file directly. Then, restart Dify with:
Modify the environment variable values in your local `.env` file, then restart Dify to apply the changes:
```
docker compose down
@@ -175,9 +145,15 @@ docker compose up -d
```
<Tip>
The full set of annotated environment variables along can be found under `docker/.env.example`. For more information, see [environment variables](/en/self-host/configuration/environments).
For more information, see [environment variables](/en/self-host/configuration/environments).
</Tip>
## Read More
## Upgrade Dify
If you have any questions, see [FAQs](/en/self-host/quick-start/faqs).
Upgrade steps may vary between releases. Refer to the upgrade guide for your target version provided in the [Releases](https://github.com/langgenius/dify/releases) page.
<Note>
After upgrading, check whether the `.env.example` file has changed and update your local `.env` file accordingly.
</Note>