OPINIONATED OMARCHY
TROUBLESHOOTING CORPUS
790
RECORDS
790
AUDITED
0
UNCHECKED
2388
SOURCES
LIVE
apps-services medium common DISPUTE

Let a Docker container reach Ollama or another service on the host through ufw

omarchyarchdockerdocker-composeufwollamadesktoplaptop
AUDITED Audited against its sources and confirmed accurate. · checked against Omarchy omarchy 4.0.4-1 on 2026-10-05
AUDIT NOTE

/etc/docker/daemon.json on 4.0.4-1 is owned by omarchy-settings and sets "bip": "172.17.0.1/16" and dns 172.17.0.1. firewall.sh runs 'ufw default deny incoming', adds the two 'allow-docker-dns' rules for UDP 53 to 172.17.0.1 only, and installs ufw-docker, whose rules sit in DOCKER-USER on the FORWARD path, so traffic from a container to the host's own address is judged by ufw's INPUT rules as the record says. /usr/share/omarchy/install/config/docker.sh documents that the user is deliberately not added to the docker group and that omarchy-setup-security-sudoless-docker opts back in. The Ollama FAQ (docs/faq.mdx on ollama/ollama main) says Ollama binds 127.0.0.1:11434 by default and gives the 'systemctl edit ollama.service' drop-in with Environment="OLLAMA_HOST=0.0.0.0:11434" verbatim. The scoped rule 'ufw allow from 172.28.7.0/24 to any port 11434 proto tcp' and the pinned compose subnet are what this repo's Skill Bench used to reach Ollama through ufw on this host. Not exercised by this audit: no container was run and no rule was added.

RISK

OLLAMA_HOST=0.0.0.0 exposes an unauthenticated API on every interface. It is safe only while ufw's default deny holds, so check sudo ufw status for any broad allow on 11434.

Symptom

Open WebUI (or any container) cannot talk to Ollama running on the same machine. curl http://localhost:11434/api/version works on the host. From the container either curl: (6) Could not resolve host: host.docker.internal, or curl: (7) Failed to connect to host.docker.internal port 11434: Connection refused, or, most confusingly, a long hang ending in curl: (28) Failed to connect to host.docker.internal port 11434 after 130000 ms: Couldn't connect to server. A rule that worked yesterday stops working after docker compose down && up.

Cause

Three separate layers, each with its own error.

  1. **No name.** On Linux host.docker.internal does not exist unless the container is given extra_hosts: host.docker.internal:host-gateway, which resolves to the default bridge gateway. Omarchy's /etc/docker/daemon.json sets "bip": "172.17.0.1/16", so that is 172.17.0.1.
  2. **Connection refused.** Ollama binds 127.0.0.1:11434 by default, so nothing listens on 172.17.0.1.
  3. **Timeout.** Omarchy runs ufw with default deny incoming. A packet from a container to the host's own address goes through the INPUT hook, not FORWARD, so neither ufw-docker's DOCKER-USER rules nor Omarchy's shipped allow-docker-dns rules (UDP 53 to 172.17.0.1 only) cover it, and ufw drops it silently. That is why it times out instead of being refused.

Compose makes the third layer move. Every project network gets a new br-<id> bridge and a subnet from Docker's default pools when it is created, so a ufw rule naming the interface or one subnet stops matching after the network is recreated.

Fix

**1. Make Ollama listen beyond loopback** (the Ollama FAQ's method for a systemd install):


sudo systemctl edit ollama.service

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"

sudo systemctl restart ollama
ss -ltn | grep 11434          # expect *:11434 or 0.0.0.0:11434

Binding 172.17.0.1:11434 instead also works, but only if docker0 already exists when Ollama starts.

**2. Pin the compose network and give the container the host name:**


services:
  webui:
    image: ghcr.io/open-webui/open-webui:main
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      OLLAMA_BASE_URL: http://host.docker.internal:11434
    networks: [llm]

networks:
  llm:
    name: llm
    driver: bridge
    driver_opts:
      com.docker.network.bridge.name: br-llm
    ipam:
      config:
        - subnet: 172.28.7.0/24

**3. Open the port to that subnet only** (Omarchy 4, or any Arch with ufw):


sudo ufw allow from 172.28.7.0/24 to any port 11434 proto tcp comment 'ollama from compose llm'
# containers started with plain docker run sit on docker0 instead:
sudo ufw allow in on docker0 to any port 11434 proto tcp comment 'ollama from docker0'

Do not use sudo ufw allow 11434. That opens Ollama, which has no authentication, to your whole LAN.

On plain Arch without ufw, steps 1 and 2 are enough. Omarchy leaves your user out of the docker group, so run the compose commands with sudo unless you opted in to sudoless Docker.

Verify


sudo docker run --rm --network llm --add-host host.docker.internal:host-gateway \
  curlimages/curl -s http://host.docker.internal:11434/api/version

prints a JSON version string immediately. sudo ufw status | grep 11434 shows only the scoped rules.

Sources

docker-container-cannot-reach-host-service-ufw