open-webui镜像启动失败

/ 默认分类 / 没有评论 / 273浏览

发现镜像启动几秒后就退出了。于是使用 logs命令查看docker镜像启动的日志。

(base) maruifu@maruifudeMBP ~ % docker ps
CONTAINER ID   IMAGE                                COMMAND           CREATED         STATUS         PORTS                     NAMES
948e39d916a7   ghcr.io/open-webui/open-webui:main   "bash start.sh"   7 seconds ago   Up 7 seconds   0.0.0.0:11433->8080/tcp   ollama-webui
(base) maruifu@maruifudeMBP ~ % docker logs 948e39d916a7
/usr/local/lib/python3.11/site-packages/pydantic/_internal/_fields.py:160: UserWarning: Field "model_name" has conflict with protected namespace "model_".
...此处省略不到十万行...
Error while downloading from https://cdn-lfs.huggingface.co/sentence-transformers/all-MiniLM-L6-v2/53aa51172d142c89d9012cce15ae4d6cc0ca6895895114379cacb4fab128d9db?response-content-disposition=attachment%3B+filename*%3DUTF-
...此处省略不到n字...
OMPD-a1GbAkTR-neqjRjVYVKfO9sbkdU13%7ESK1fbWgSQ__&Key-Pair-Id=KVTP0A1DKRTAX: HTTPSConnectionPool(host='cdn-lfs.huggingface.co', port=443): Read timed out.
Trying to resume download...

看了日志才知道,原来是open-webui启动时期需要首先在线安装transformers库,但是huggingface.co对于国内来说是经常不可访问):

  于是赶紧求助bing,找到一个镜像网站,"hf-mirror.com",于是给docker启动命令中增加一个环境变量"HF_ENDPOINT",经测试完美解决了。后来又想到开始虽然运行镜像启动成功了,但是启动特别慢,2、3分钟服务才能访问,看来也是需要访问huggingface网站的原因。

  注意这里设置环境变量HF_ENDPOINT,必须设置为”https://hf-mirror.com“,否则依然会报错,大概是说未知的scheme,我已经趟过这个坑了。完整的命令行如下:

docker run -d \
   --restart unless-stopped \
   --name ollama-webui \
   -p 11433:8080 \
   -v /Users/maruifu/work/ai-code/ollama/data:/app/backend/data \
   -e OLLAMA_API_BASE_URL=http://127.0.0.1:11434/api \
   -e HF_ENDPOINT=https://hf-mirror.com \
   -e WEBUI_SECRET_KEY=12345678 \
   ghcr.io/open-webui/open-webui:main