Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): unable to use CLI within the container #4023

Closed
wants to merge 1 commit into from

Conversation

BlackHole1
Copy link

In the container, OLLAMA_HOST is set by default to 0.0.0.0 (ref: Dockerfile#L137), which is fine when starting the server. However, as a client, it is must to use 127.0.0.1 or localhost for requests.

fix: #3521 #1337
maybe fix: #3526

In the container, `OLLAMA_HOST` is set by default to `0.0.0.0` (ref: [Dockerfile#L137]), which is fine when starting the server.
However, as a client, it is must to use `127.0.0.1` or `localhost` for requests.

fix: ollama#3521 ollama#1337
maybe fix: ollama#3526

[Dockerfile#L137]: https://github.com/ollama/ollama/blob/7e432cdfac51583459e7bfa8fdd485c74a6597e7/Dockerfile#L137

Signed-off-by: Kevin Cui <bh@bugs.cc>
@pdevine
Copy link
Contributor

pdevine commented May 6, 2024

Hey @BlackHole1 , thanks for the PR. Unfortunately this change would break ollama for a lot of people who want to host the server on 0.0.0.0. I don't believe the docker issues you cited are related to this. I'm going to go ahead and close the issue, but thank you for taking the time to try and fix it.

@pdevine pdevine closed this May 6, 2024
@BlackHole1
Copy link
Author

@pdevine I have a different perspective on this. The changes in this PR only affect the client, not the server. So host the server on 0.0.0.0 issue you mentioned does not exist in my opinion.

@BlackHole1
Copy link
Author

BlackHole1 commented May 7, 2024

If OLLAMA_HOST is 0.0.0.0, the server will still listen on 0.0.0.0 when it is listening. It will just be changed to 127.0.0.1 when making requests using the CLI.

@mxyng
Copy link
Contributor

mxyng commented May 7, 2024

A client source address of 0.0.0.0 is valid since it represents all available network interfaces on the local machine. As Patrick suggested, if it doesn't work in the container, it likely a Docker issue

$ curl -v 0.0.0.0:11434/api/tags
*   Trying 0.0.0.0:11434...
* Connected to 0.0.0.0 (127.0.0.1) port 11434
> GET /api/tags HTTP/1.1
> Host: 0.0.0.0:11434
> User-Agent: curl/8.4.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Date: Tue, 07 May 2024 00:21:30 GMT
< Content-Length: 13
<
* Connection #0 to host 0.0.0.0 left intact
{"models":[]}

@BlackHole1 BlackHole1 deleted the fix-client-request-failed branch May 7, 2024 01:43
@BlackHole1
Copy link
Author

@mxyng I get it. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ollama fails to start in CPU only mode Run ollama list/pull got an error
3 participants