硬件要求
在安装Dify之前,请确保您的系统满足以下最低要求:
CPU: 至少2核心(推荐4核心或更高)
内存: 至少4GB RAM(推荐8GB或更高)
存储空间: 至少20GB可用空间
网络: 稳定的互联网连接,用于拉取Docker镜像
本篇文章采用docker部署dify
docker安装
Docker: 版本19.03或更高
Docker Compose: 版本1.28或更高(或Docker Compose V2)
1.开启Hyper-V
可在开始栏搜索hyper-v快速安装
参考 hyper-v的安装和基本使用方法
2.安装docker
访问 Docker 官网:https://www.docker.com 需要开启vpn以访问
点击页面上的“Download for Windows - AMD64”按钮,以下载适用于 Windows 系统的 Docker Desktop 安装文件。
3.配置文件换源
将以下的json复制下来并替换原先的配置
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://docker.imgdb.de",
"https://docker-0.unsee.tech",
"https://docker.hlmirror.com",
"https://docker.1ms.run",
"https://func.ink",
"https://lispy.org",
"https://docker.xiaogenban1993.com"
]
}
4.测试
运行下面的两串代码
docker --version
docker run hello-world
输出以下信息,则说明安装成功
C:\Users\lynnh>docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:7f0a9f93b4aa3022c3a4c147a449bf11e0941a1fd0bf4a8e6c9408b2600777c5
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
docker run hello-world会先从本地搜索名为hello-world的镜像,若没有找到,则先从docker hub中pull该镜像,拉取镜像到本地成功后,再通过run指令来启动容器运行该镜像。
dify安装
1.安装
方式一:克隆GitHub仓库(推荐)
# 克隆最新版本
git clone https://github.com/langgenius/dify.git
# 或克隆特定稳定版本(推荐用于生产环境)
git clone https://github.com/langgenius/dify.git --branch 0.15.3
# 进入项目目录
cd dify/docker`
方式二:直接下载必要文件
如果您无法使用git,可以直接下载必要的配置文件:
//创建项目目录
mkdir -p dify-docker && cd dify-docker
//下载docker-compose配置
curl -fsSL https://github.com/langgenius/dify/raw/main/docker/docker-compose.yaml -o docker-compose.yaml
//下载环境变量模板
curl -fsSL https://github.com/langgenius/dify/raw/main/docker/.env.example -o .env
2.启动Docker服务
cd dify/docker //关键目录
cp .env.example .env # 复制环境变量模板 如果提示找不到命令则改用 copy .env.example .env
docker compose up -d # 后台启动docker,会自动拉取镜像
过程会有点长,或出现拉取失败的情况,如果遇到拉取失败,一般都是docker镜像源问题,请参考上面的坑的解决方案,正常情况会看到如下:
等待镜像拉取完成后自动启动相关的镜像:
3.验证
启动后,检查所有容器是否正常运行:
docker compose ps
浏览器中输入:http://localhost
首次进入会要设置管理员账号密码啥的,随便设置一个登录,然后就可以看到类似如下界面:
到这一步,则基本部署成功了。