Dify 部署问题处理
Dify介绍
Dify 是一款开源的大语言模型(LLM) 应用开发平台。它融合了后端即服务(Backend as Service)和 LLMOps 的理念,使开发者可以快速搭建生产级的生成式 AI 应用。即使你是非技术人员,也能参与到 AI 应用的定义和数据运营过程中。
问题1:docker_api_1 、docker_worker_1 服务和docker_sandbox_1 组件一直处于restarting
docker_api_1 /bin/bash /entrypoint.sh Restarting
docker_db_1 docker-entrypoint.sh postg ... Up (healthy) 5432/tcp
docker_nginx_1 sh -c cp /docker-entrypoin ... Up 0.0.0.0:444->443/tcp,:::444->443/tcp, 0.0.0.0:7002->80/tcp,:::7002->80/tcp
docker_plugin_daemon_1 /bin/bash -c /app/entrypoi ... Up 0.0.0.0:5003->5003/tcp
docker_redis_1 docker-entrypoint.sh redis ... Up (healthy) 6379/tcp
docker_sandbox_1 /main Restarting
docker_ssrf_proxy_1 sh -c cp /docker-entrypoin ... Up 3128/tcp
docker_weaviate_1 /bin/weaviate --host 0.0.0 ... Up
docker_web_1 /bin/sh ./entrypoint.sh Up 3000/tcp
docker_worker_1 /bin/bash /entrypoint.sh Restarting
刚开始按照 https://github.com/langgenius/dify/discussions/12312 将docker-compose.yaml 配置文件中LOG_FILE: ${LOG_FILE:-/app/logs/server.log} 调整为LOG_FILE: /app/logs/server.log 然后重启后,docker_api_1 暂时恢复正常,另外两个仍然异常。(为何是暂时,因为后面docker_api_1 又处于restarting状态)
这时查看服务日志
docker logs docker_sandbox_1
docker logs docker_worker_1
错误内容提示:
OpenBLAS blas_thread_init: pthread_create failed for thread 2 of 4: Operation not permitted
runtime/cgo: pthread_create failed :Operation not permitted
解决方法:添加特权运行配置
推测是容器权限不够,准备在docker-compose.yaml中添加特权运行配置内容。需要将docker_api_1 、docker_worker_1 docker_sandbox_1 都添加特权运行。
docker_api_1
api:image: langgenius/dify-api:1.4.1restart: alwaysprivileged: true
docker_worker_1
worker:image: langgenius/dify-api:1.4.1restart: alwaysprivileged: true
docker_sandbox_1
sandbox:image: langgenius/dify-sandbox:0.2.12restart: alwaysprivileged: true
然后重新启动
docker compose down
docker compose up -d
重新查看服务都起来了,若是其他服务查看日志也是权限问题,按照此方法添加特权运行即可。
问题2:安装模型供应商提示【init environment for plugin langgenius/openai:0.0.26 failed too many times you should consider the package is corrupted or your network is unstable】
不论是在线安装还是离线安装都是安装失败。
查看docker_plugin_daemon_1 组件日志,
docker logs docker_plugin_daemon_1
错误显示 operation not permitted,还是权限问题
解决方法: docker_plugin_daemon 添加特权配置内容
在docker-compose.yaml 对docker_plugin_daemon_1 添加特权运行配置
plugin_daemon:image: langgenius/dify-plugin-daemon:0.1.1-localrestart: alwaysprivileged: true
然后重启
docker-compose down
docker-compose up -d
这时重新安装还是失败,重新查看ocker_plugin_daemon_1 日志,提示
[ERROR]init environment failed: failed to install dependencies: exit status 2, output: error: Failed to unzip wheel: openai-1.64.0-py3-none-any.whlCaused by: an upstream reader returned an error: io error occurred: HTTP status client error (403 Forbidden) for url (https://pypi.tuna.tsinghua.edu.cn/packages/9a/e6d503e1ea474522b2a15a904bb/openai-1.64.0-py3-none-any.whl)Caused by: io error occurred: HTTP status client error (403 Forbidden) for url (https://pypi.tuna.tsinghua.edu.cn/packages/9a/1a/e62718f311daa26d208800976d7944e5ee64.0-py3-none-any.whl)Caused by: HTTP status client error (403 Forbidden) for url (https://pypi.tuna.tsinghua.edu.cn/packages/9a/1a/e62718f311daa26d208800976d7944e5ee6d503e1ea474522b2a15l)
之前修改过.env 配置的 PIP_MIRROR_URL 内容,看报错是这个配置导致的,调整pip源
解决方法:修改 .env配置文件中 PIP_MIRROR_URL值
PIP_MIRROR_URL 设置为:https://mirrors.aliyun.com/pypi/simple/
然后重新启动Dify
docker compose down
docker compose up -d
这时安装模型供应商插件安装成功