docker安裝OpenWebUI報錯500的原因及解決方法
你在訪問 Web UI 時遇到 500 錯誤,可能是由于以下幾個原因?qū)е碌模?/p>
1. ??OpenAI 配置沖突??
從配置中可以看到:
json
"openai": {
"enable": true, // 開啟
"api_base_urls": ["https://api.openai.com/v1"],
"api_keys": [""], // 密鑰為空
"api_configs": {"0":{}}
}
當(dāng) openai.enable=true 時,系統(tǒng)會嘗試調(diào)用 OpenAI 的接口,但你的 api_keys 為空,會導(dǎo)致服務(wù)端認(rèn)證失敗。
如果服務(wù)端沒有正確處理空密鑰的情況,會直接拋出 500 錯誤。
2.解決方案:??
如果不需要 OpenAI 功能,保持 enable: false。
"openai": {
"enable": false, // 已被你禁用
"api_base_urls": ["https://api.openai.com/v1"],
"api_keys": [""], // 密鑰為空
"api_configs": {"0":{}}
}
如果需要 OpenAI,需填寫有效的 API 密鑰:
json
"openai": {
"enable": true,
"api_keys": ["sk-your-api-key-here"] // 替換為有效密鑰
}
3.關(guān)閉OpenAI 功能解決辦法
??1. 查看容器掛載詳情?
[root@koji-builder ~]# docker inspect open-webui | grep -A 10 "Mounts"
"Mounts": [
{
"Type": "volume",
"Name": "open-webui",
"Source": "/var/lib/docker/volumes/open-webui/_data",
"Destination": "/app/backend/data",
"Driver": "local",
"Mode": "z",
"RW": true,
"Propagation": ""
}
[root@koji-builder ~]#
2.定位文件位置
[root@koji-builder ~]# cd /var/lib/docker/volumes/open-webui/_data [root@koji-builder _data]# ls cache uploads vector_db webui.db [root@koji-builder _data]#
??2. 修改修改 config 表中 openai.enable 字段
如果不修改的話,會報500,因為openwebui使用了openai的api,如果不能訪問外網(wǎng)的情況下,需要修改數(shù)據(jù)庫表的openai.enable 字段
1.安裝sqlite
yum install sqlite
2.備份數(shù)據(jù)庫和停止 Open WebUI 容器?
sudo cp webui.db webui.db.bak #停止 Open WebUI 容器? docker stop open-webui
3. 進(jìn)入 SQLite 交互模式?
[root@koji-builder _data]# sqlite3 webui.db SQLite version 3.26.0 2018-12-01 12:34:55 Enter ".help" for usage hints. sqlite>
4. 查看所有表,是否有config 表
sqlite> .tables alembic_version config group model auth document knowledge prompt channel feedback memory tag channel_member file message tool chat folder message_reaction user chatidtag function migratehistory sqlite>
5. 修改config 表"openai":{"enable"是的修改true
#修改
sqlite> UPDATE config
...> SET data = json_set(
...> data,
...> '$.openai.enable',
...> json('false')
...> )
...> WHERE id = 1;
#-- 驗證結(jié)果
sqlite> SELECT json_extract(data, '$.openai.enable') FROM config WHERE id = 1;
0
6. 查看config 表中的"openai":{"enable"是的修改false
sqlite> select * from config;
1|{"version":0,"ui":{"default_locale":"","prompt_suggestions":[{"title":["Help me study","vocabulary for a college entrance exam"],"content":"Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option."},{"title":["Give me ideas","for what to do with my kids' art"],"content":"What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter."},{"title":["Tell me a fun fact","about the Roman Empire"],"content":"Tell me a random fun fact about the Roman Empire"},{"title":["Show me a code snippet","of a website's sticky header"],"content":"Show me a code snippet of a website's sticky header in CSS and JavaScript."},{"title":["Explain options trading","if I'm familiar with buying and selling stocks"],"content":"Explain options trading in simple terms if I'm familiar with buying and selling stocks."},{"title":["Overcome procrastination","give me tips"],"content":"Could you start by asking me about instances when I procrastinate the most and then give me some suggestions to overcome it?"},{"title":["Grammar check","rewrite it for better readability "],"content":"Check the following sentence for grammar and clarity: \"[sentence]\". Rewrite it for better readability while maintaining its original meaning."}],"enable_signup":false},"ollama":{"enable":true,"base_urls":["http://172.16.104.203:11434"],"api_configs":{"0":{}}},"openai":{"enable":false,"api_base_urls":["https://api.openai.com/v1"],"api_keys":[""],"api_configs":{"0":{}}}}|0|2025-04-14 08:07:08|2025-04-14 08:50:11.453672
sqlite>
#-- 退出
sqlite> .quit
7. 重啟open-webui容器
[root@koji-builder _data]# docker start open-webui open-webui
如果啟動后沒有反應(yīng)需要進(jìn)容器里啟動 [root@koji-builder _data]# docker exec -it open-webui /bin/bash root@69d9b2ad6b44:/app/backend# ls data dev.sh open_webui requirements.txt start.sh start_windows.bat root@69d9b2ad6b44:/app/backend# ./start.sh
??3. 訪問open-webui
http://ip:3000

總結(jié)
到此這篇關(guān)于docker安裝OpenWebUI報錯500的原因及解決方法的文章就介紹到這了,更多相關(guān)docker安裝OpenWebUI報錯500內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Docker使用nodejs鏡像構(gòu)建express服務(wù)的方法
這篇文章主要介紹了Docker使用nodejs鏡像構(gòu)建express服務(wù),主要包括nodejs容器的啟動,安裝nodejs第三方依賴模塊及啟動nodejs服務(wù)的相關(guān)操作,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下2022-07-07
docker容器狀態(tài)轉(zhuǎn)換管理命令實例詳解
Docker容器只是一個運行于宿主操作系統(tǒng)host?OS上的應(yīng)用進(jìn)程,所以你需要一個鏡像來運行它,Docker鏡像以進(jìn)程的方式運行時就叫做Docker容器,這篇文章主要給大家介紹了關(guān)于docker容器狀態(tài)轉(zhuǎn)換管理命令的相關(guān)資料,需要的朋友可以參考下2022-05-05

