Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Confused About Docker (container talking to a service running on host's localhost)

raindog308raindog308 Administrator, Veteran

I have a Debian 12 VPS with Ollama running on 127.0.0.1:11434.

Ollama itself is working just fine:

# curl http://127.0.0.1:11434/api/tags
{"models":[{"name":"tinyllama:latest","model":"tinyllama:latest","modified_at":"2025-08-04T06:07:47.745085927-07:00","size":637700138,"digest":"2644915ede352ea7bdfaff0bfac0be74c719d5d5202acb63a6fb095b52f394a4","details":{"parent_model":"","format":"gguf","family":"llama","families":["llama"],"parameter_size":"1B","quantization_level":"Q4_0"}}]}

I fired up open-webui in docker and created an Nginx reverse proxy and all that is working fine (i.e., the openui web page works), but not seeing any models available. This is because in the container's logs I see:

(line breaks for LET)

2025-08-04 20:13:05.636 | ERROR    \
| open_webui.routers.ollama:send_get_request:106 - \
Connection error: Cannot connect to host host.docker.internal:11434 \
ssl:default [Connect call failed ('172.17.0.1', 11434)] - {}

And:

# docker exec -it open-webui curl http://host.docker.internal:11434/api/tags
curl: (7) Failed to connect to host.docker.internal port 11434 after 0 ms: \
Couldn't connect to server

This makes me sad.

My docker-compose.yaml:

services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:${WEBUI_DOCKER_TAG-main}
    container_name: open-webui
    volumes:
      - open-webui:/app/backend/data
    ports:
      - ${OPEN_WEBUI_PORT-3000}:8080
    environment:
      - OLLAMA_BASE_URL=http://host.docker.internal:11434
      - DEBUG=true
    extra_hosts:
        - host.docker.internal:host-gateway
    restart: unless-stopped

volumes:
  open-webui: {}

I thought host.docker.internal and the extra_hosts was magic that bound 127.0.0.1 to host.docker.internal?

Comments

  • plumbergplumberg Veteran, Megathread Squad

    Did you try turning it on and off?

    Thanked by 2barbarza admax
  • plumbergplumberg Veteran, Megathread Squad

    Ok

    I use --net="host"

    And it usually works for me

    Thanked by 1yoursunny
  • raindog308raindog308 Administrator, Veteran

    @plumberg said: --net="host"

    My googling suggests that is what extra_hosts is doing - ?

    Thanked by 1plumberg
  • wadhahwadhah Member, Host Rep
    edited August 2025

    try this

        extra_hosts:
          - host.docker.internal:172.17.0.1
    

    This works for my caddy so it talks to an app on localhost

    Also make sure your firewall is allowing the connection to the localhost

  • olokeoloke Member, Host Rep
    edited August 2025

    As you mentioned, ollama is running on 127.0.0.1:11434. It works when you access it on localhost.

    With the command docker exec -it open-webui curl http://host.docker.internal:11434/api/tags you are try to access ollama on 172.17.0.1:11434 (not localhost).

    Docker container does not have access to your host's localhost. Instead, it shares a docker0 interface with the host and you can access host's services listening on it.

    10: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
        link/ether f2:50:40:9f:7f:67 brd ff:ff:ff:ff:ff:ff
        inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
           valid_lft forever preferred_lft forever
    

    I would try making ollama listen on 172.17.0.1 or 0.0.0.0. Then docker container should be able to access it as you tried before :)

  • raindog308raindog308 Administrator, Veteran

    @oloke said: I would try making ollama listen on 172.17.0.1

    This fixed it. Thank you @oloke !

    image

  • emghemgh Member, Megathread Squad

    Would it have worked with network_mode: host? I usually do that works great

    Thanked by 1ashish168527
  • @emgh said:
    Would it have worked with network_mode: host? I usually do that works great

    Doesn't matters anymore, if it works don't touch it :p

    Thanked by 2emgh plumberg
  • @plumberg said:
    Did you try turning it on and off?

    100% fail.

    Turn it off then on.

  • CfrCfr Member
    edited August 2025

    Ollama is quite unprotected on host/loopback listening. I personally run Ollama with a static IP in a private /29 bridge network with internal: true to shut it off from other networks/public internet. Then run OpenWebUI in its own bridge that's internal: false for internet connectivity and then simply attach it to the private internal bridge network where Ollama resides and have it directly connect to its static bridge IP. This ensures only OpenWebUI gets to access it with its somewhat authentication in front of it.

    In case you're wondering how the hell I get my models loaded into Ollama from outside: I don't use the WebUI for that because it's rather slow. I simply aria/wget the .gguf files directly from Hugging Face onto a mounted directory that the Ollama container has access to and then simpy run docker exec -it ollama /opt/ollama/ollama create --file /models/llama3/prepared_Modelfile Llama3-model-lowendyapping where it's most important to have the FROM part right in the Modelfile: FROM /models/llama3/llama3-model.gguf

    The file wgetting and importing is drastically faster this way.

    Thanked by 1quicksilver03
Sign In or Register to comment.