> ## Documentation Index
> Fetch the complete documentation index at: https://enterprise-docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker Compose

## 要求

* 发布日志：[https://langgenius.github.io/dify-enterprise-docker-compose/](https://langgenius.github.io/dify-enterprise-docker-compose/)
* Docker
* Docker Compose
* Linux 服务器
  * **警告**：不支持 Windows 和 Mac 上的 Docker Desktop
  * 最低配置要求：4 核 CPU、16 GB 内存、100 GB 磁盘空间

## 快速开始

### 下载

你可以从 Dify Enterprise 的 [仓库](https://langgenius.github.io/dify-enterprise-docker-compose/) 中下载特定版本。

使用 wget：

```bash theme={null}
wget https://langgenius.github.io/dify-enterprise-docker-compose/dify-docker-compose-<version>.tgz
```

使用 curl：

```bash theme={null}
curl -O https://langgenius.github.io/dify-enterprise-docker-compose/dify-docker-compose-<version>.tgz
```

## 安装步骤

1. 解压下载的文件到你的部署目录：

   ```bash theme={null}
   mkdir dify-enterprise
   tar -xzf dify-docker-compose-<version>.tgz -C ./dify-enterprise/
   ```

2. 启动 Docker Compose：

   ```bash theme={null}
   cd dify-enterprise
   docker compose up -d
   ```

3. 如何访问 Dify Enterprise
   * 获取服务器的 IP，并在本地修改 hosts 文件，将域名指向该 IP，例如：
   ```bash theme={null}
   4.152.1.216 console.dify.local
   4.152.1.216 app.dify.local
   4.152.1.216 api.dify.local
   4.152.1.216 upload.dify.local
   4.152.1.216 enterprise.dify.local
   ```

4. [验证服务状态](/versions/3-0-x/zh-cn/deployment/verify-services-status)

5. [激活许可证](/versions/3-0-x/zh-cn/deployment/license-activation)

## 从社区版升级

1. 创建企业版数据库（确保社区版正在运行）：

   ```bash theme={null}
   docker exec -it dify-db-1 psql -U postgres -c "CREATE DATABASE enterprise;" -c "CREATE DATABASE audit;"
   ```

   **提示**：你可能需要根据实际运行的容器名称做调整，可使用 `docker container ls` 查看 `db` 容器名称。

2. 停止社区版服务：

   ```bash theme={null}
   docker compose down
   ```

3. 备份数据和配置（可能需要 sudo）：

   ```bash theme={null}
   tar -czf backup.tgz volumes .env  # 如有其他自定义文件夹请一并备份
   ```

4. 删除社区版的所有文件和文件夹，仅保留 `backup.tgz` 和 `dify-docker-compose-<version>.tgz`

5. 解压企业版安装包到部署目录：

   ```bash theme={null}
   tar -xzf dify-docker-compose-<version>.tgz -C /path/to/directory
   ```

6. 恢复备份：先删除 volumes 文件夹

   ```bash theme={null}
   rm -rf volumes
   ```

   然后执行：

   ```bash theme={null}
   tar -xzf backup.tgz
   ```

7. 如果你有自定义配置（如 `docker-compose.yaml`、`ssrf_proxy/squid.conf`、或 `nginx/conf.d/default.conf`），请手动合并修改。

8. 启动 Docker Compose：

   ```bash theme={null}
   docker compose up -d
   ```

9. 如何访问 Dify Enterprise:
   * 获取服务器的 IP，并在本地修改 hosts 文件，将域名指向该 IP，例如：
   ```bash theme={null}
   4.152.1.216 console.dify.local
   4.152.1.216 app.dify.local
   4.152.1.216 api.dify.local
   4.152.1.216 upload.dify.local
   4.152.1.216 enterprise.dify.local
   ```

10. [验证服务状态](/versions/3-0-x/zh-cn/deployment/verify-services-status)

11. [激活许可证](/versions/3-0-x/zh-cn/deployment/license-activation)

## 从旧的企业版升级

1. 备份数据和配置（可能需要 sudo）：

   ```bash theme={null}
   tar -czf backup.tgz volumes .env  # 如有其他自定义文件夹请一并备份
   ```

2. 删除旧版的所有文件和文件夹，仅保留 `backup.tgz` 和 `dify-docker-compose-<version>.tgz`

3. 解压新版本文件到部署目录：

   ```bash theme={null}
   tar -xzf dify-docker-compose-<version>.tgz -C /path/to/directory
   ```

4. 恢复备份：先删除 volumes 文件夹

   ```bash theme={null}
   rm -rf volumes
   ```

   然后执行：

   ```bash theme={null}
   tar -xzf backup.tgz
   ```

5. 如果你有自定义配置（如 `docker-compose.yaml`、`ssrf_proxy/squid.conf`、或 `nginx/conf.d/default.conf`），请手动合并修改。

6. 启动 Docker Compose：

   ```bash theme={null}
   docker compose up -d
   ```

## 高级配置

### 域名要求

Dify Enterprise 要求配置以下 5 个域名：

* Console: console.dify.local
* Services API: api.dify.local
* APP: app.dify.local
* Files: upload.dify.local
* Enterprise: enterprise.dify.local

你可以在 `.env` 文件中配置这些域名：

```bash theme={null}
# .env

CONSOLE_API_URL="http://console.dify.local"
CONSOLE_WEB_URL="http://console.dify.local"
SERVICE_API_URL="http://api.dify.local"
APP_API_URL="http://app.dify.local"
APP_WEB_URL="http://app.dify.local"
FILES_URL="http://upload.dify.local"
ENTERPRISE_URL="http://enterprise.dify.local"
```

### 持久化存储配置

默认使用本地存储。如需修改，可在 `.env` 文件中配置。例如使用 **AWS S3**：

```bash theme={null}
# .env

STORAGE_TYPE=s3

S3_USE_AWS_MANAGED_IAM=
S3_ENDPOINT=
S3_REGION=
S3_BUCKET_NAME=
S3_ACCESS_KEY=
S3_SECRET_KEY=
```

更多存储选项配置，请参考：[文件存储配置指南](https://docs.dify.ai/getting-started/install-self-hosted/environments#file-storage-configuration)

### Postgres 数据库配置

```bash theme={null}
# .env

DB_USERNAME=postgres
DB_PASSWORD=difyai123456
DB_HOST=db
DB_PORT=5432
DB_DATABASE=dify
```

更多数据库配置，请参考：[数据库配置指南](https://docs.dify.ai/getting-started/install-self-hosted/environments#database-configuration)

### Redis 数据库配置

```bash theme={null}
# .env

REDIS_HOST=redis
REDIS_PORT=6379
REDIS_USERNAME=
REDIS_PASSWORD=difyai123456
REDIS_USE_SSL=false
REDIS_DB=0
```

更多配置，请参考：[Redis 配置指南](https://docs.dify.ai/getting-started/install-self-hosted/environments#redis-configuration)

### 向量数据库配置

默认使用 **Weaviate**，如需切换为 **Qdrant**，可以在 `.env` 文件中配置如下：

```bash theme={null}
# .env

VECTOR_STORE=qdrant

QDRANT_URL=http://qdrant:6333
QDRANT_API_KEY=difyai123456
QDRANT_CLIENT_TIMEOUT=20
QDRANT_GRPC_ENABLED=false
QDRANT_GRPC_PORT=6334
```

更多向量数据库配置，请参考：[向量数据库配置指南](https://docs.dify.ai/getting-started/install-self-hosted/environments#vector-database-configuration)

### 更多配置项

请参考官方文档：[环境变量说明](https://docs.dify.ai/getting-started/install-self-hosted/environments) 获取更多高级配置。
