安装和自启动
1 | curl -fsSL https://ollama.com/install.sh | sh |
版本更新
1 | curl -fsSL https://ollama.com/install.sh | sh |
直接执行模型,命令行交互
1 | ollama run deepseek-llm |
其他常用操作
1 | ollama list # 显示已安装模型列表 |
TroubleShoot1
docker容器无法连接宿主机的ollama服务
现象容器内部curl报错:
Failed to connect to 172.17.0.1 port 11434 after 0 ms: Connection refused
Failed to connect to host.docker.internal port 11434 after 0 ms: Connection refused
anythingllm报错:
Your Ollama instance could not be reached or is not responding. Please make sure it is running the API server and your connection information is correct in AnythingLLM.
原因
ollama服务默认监听127.0.0.1的11434端口,无法为容器提供服务。
127.0.0.1 和 0.0.0.0 的监听区别:
- 127.0.0.1(localhost 监听)
仅允许 本机访问,外部设备或 Docker 容器 无法访问。 - 0.0.0.0(全网监听)
允许来自 任何网络接口 的连接,包括本机、局域网和互联网。
解决方法
修改ollama服务的配置,通过0.0.0.0监听
1 | systemctl edit ollama.service |