Docker Compose 部署
官方手册:https://docs.dify.ai/zh-hans/getting-started/install-self-hosted/docker-compose
克隆 Dify 代码仓库
通过windows命令行,进入存放digy源码的目录,克隆 Dify 源代码至本地环境。
git clone https://github.com/langgenius/dify.git
启动 Dify
2、进入 Dify 源代码的 Docker 目录
cd dify/docker
3、复制环境配置文件
cp .env.example .env
4、启动 Docker 容器
如果版本是 Docker Compose V2,使用以下命令:
docker compose up -d
如果版本是 Docker Compose V1,使用以下命令:
docker-compose up -d
ps:docker -v 查看版本
运行命令后,你应该会看到类似以下的输出,显示所有容器的状态和端口映射:
[+] Running 11/11
✔ Network docker_ssrf_proxy_network Created 0.1s
✔ Network docker_default Created 0.0s
✔ Container docker-redis-1 Started 2.4s
✔ Container docker-ssrf_proxy-1 Started 2.8s
✔ Container docker-sandbox-1 Started 2.7s
✔ Container docker-web-1 Started 2.7s
✔ Container docker-weaviate-1 Started 2.4s
✔ Container docker-db-1 Started 2.7s
✔ Container docker-api-1 Started 6.5s
✔ Container docker-worker-1 Started 6.4s
✔ Container docker-nginx-1 Started 7.1s
最后检查是否所有容器都正常运行:
docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
docker-api-1 langgenius/dify-api:0.15.3 "/bin/bash /entrypoi…" api 7 minutes ago Up 7 minutes 5001/tcp
docker-db-1 postgres:15-alpine "docker-entrypoint.s…" db 7 minutes ago Up 7 minutes (healthy) 5432/tcp
docker-nginx-1 nginx:latest "sh -c 'cp /docker-e…" nginx 7 minutes ago Up 7 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp
docker-redis-1 redis:6-alpine "docker-entrypoint.s…" redis 7 minutes ago Up 7 minutes (healthy) 6379/tcp
docker-sandbox-1 langgenius/dify-sandbox:0.2.10 "/main" sandbox 7 minutes ago Up 7 minutes (healthy)
docker-ssrf_proxy-1 ubuntu/squid:latest "sh -c 'cp /docker-e…" ssrf_proxy 7 minutes ago Up 7 minutes 3128/tcp
docker-weaviate-1 semitechnologies/weaviate:1.19.0 "/bin/weaviate --hos…" weaviate 7 minutes ago Up 7 minutes
docker-web-1 langgenius/dify-web:0.15.3 "/bin/sh ./entrypoin…" web 7 minutes ago Up 7 minutes 3000/tcp
docker-worker-1 langgenius/dify-api:0.15.3 "/bin/bash /entrypoi…" worker 7 minutes ago Up 7 minutes 5001/tcp
通过这些步骤,你应该可以成功在本地安装 Dify。
docker desktop中images界面显示
访问 Dify
1、先前往管理员初始化页面设置设置管理员账户
浏览器进入http://localhost/install,设置账号密码,然后登录
Dify 主页面: http://localhost
本地部署Dify问题记录
1、docker compose up -d 无法连接
docker源设置
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"registry-mirrors": [
"https://registry.cn-hangzhou.aliyuncs.com",
"https://docker.m.daocloud.io/",
"https://dockerhub.timeweb.cloud",
"https://noohub.ru/",
"https://docker.mirrors.ustc.edu.cn"
]
}
2、git pull origin main
提示
fatal: unable to access ‘https://github.com/langgenius/dify.git/’: Failed to connect to github.com port 443 after 21177 ms: Couldn’t connect to server
解决:本机系统代理端口和git端口要一致,而且是要把git的改成跟主机原来的一致7890
主机代理服务器设置位置:
git本地代理设置
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890