[GH-ISSUE #294] Can not integrate ollama #193

Closed
opened 2026-03-02 11:47:31 +03:00 by kerem · 2 comments
Owner

Originally created by @f-mc2 on GitHub (Jul 10, 2024).
Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/294

First of all, thank you for the very nice software!

I am having trouble to integrate ollama. I installed ollama on my xubuntu 22.04 machine (CPU only), this is my docker-compose file:

services:
  web:
    image: ghcr.io/hoarder-app/hoarder-web:${HOARDER_VERSION:-release}
    restart: unless-stopped
    volumes:
      - /home/geppetto/docker/hoarder/data:/data
    ports:
      - 3000:3000
    env_file:
      - .env
    environment:
      REDIS_HOST: redis
      MEILI_ADDR: http://meilisearch:7700
      DATA_DIR: /data
  redis:
    image: redis:7.2-alpine
    restart: unless-stopped
    volumes:
      - redis:/data
  chrome:
    image: gcr.io/zenika-hub/alpine-chrome:123
    restart: unless-stopped
    command:
      - --no-sandbox
      - --disable-gpu
      - --disable-dev-shm-usage
      - --remote-debugging-address=0.0.0.0
      - --remote-debugging-port=9222
      - --hide-scrollbars
  meilisearch:
    image: getmeili/meilisearch:v1.6
    restart: unless-stopped
    env_file:
      - .env
    environment:
      MEILI_NO_ANALYTICS: "true"
    volumes:
      - meilisearch:/meili_data
  workers:
    image: ghcr.io/hoarder-app/hoarder-workers:${HOARDER_VERSION:-release}
    restart: unless-stopped
    volumes:
      - /home/geppetto/docker/hoarder/data:/data
    env_file:
      - .env
    environment:
      REDIS_HOST: redis
      MEILI_ADDR: http://meilisearch:7700
      BROWSER_WEB_URL: http://chrome:9222
      DATA_DIR: /data
      OLLAMA_BASE_URL: http://host.docker.internal:11434
    depends_on:
      web:
        condition: service_started

volumes:
  redis:
  meilisearch:
  data:

this is my .env file:

HOARDER_VERSION=release
NEXTAUTH_SECRET=***********
MEILI_MASTER_KEY=***********
NEXTAUTH_URL=http://localhost:3000
OLLAMA_BASE_URL=http://host.docker.internal:11434
INFERENCE_TEXT_MODEL=llama3
INFERENCE_IMAGE_MODEL=llava

and this is the log of docker logs hoarder-workers-1:

2024-07-10T16:19:40.177Z info: [Crawler][64] Will crawl "https://fumettologica.it/2023/02/fumettogame-fumetto-gioco/" for link with id "efe732lxi4p9fhhjvukzcbz7"
2024-07-10T16:19:40.178Z info: [Crawler][64] Attempting to determine the content-type for the url https://fumettologica.it/2023/02/fumettogame-fumetto-gioco/
2024-07-10T16:19:40.185Z info: [inference][55] Starting an inference job for bookmark with id "e8gi4ma59qoz5js8mpmkj0q8"
2024-07-10T16:19:40.188Z info: [search][72] Attempting to index bookmark with id e8gi4ma59qoz5js8mpmkj0q8 ...
2024-07-10T16:19:40.201Z error: [inference][55] inference job failed: TypeError: fetch failed
2024-07-10T16:19:40.242Z info: [Crawler][64] Content-type for the url https://fumettologica.it/2023/02/fumettogame-fumetto-gioco/ is "text/html; charset=UTF-8"
2024-07-10T16:19:40.259Z info: [search][72] Completed successfully

I tried to review previous issues on the theme (like this one), but I am absolutely not a programmer, so I failed and do not know how to proceed.

Any help would be appreciated :-)

Originally created by @f-mc2 on GitHub (Jul 10, 2024). Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/294 First of all, thank you for the very nice software! I am having trouble to integrate ollama. I installed ollama on my xubuntu 22.04 machine (CPU only), this is my docker-compose file: ``` services: web: image: ghcr.io/hoarder-app/hoarder-web:${HOARDER_VERSION:-release} restart: unless-stopped volumes: - /home/geppetto/docker/hoarder/data:/data ports: - 3000:3000 env_file: - .env environment: REDIS_HOST: redis MEILI_ADDR: http://meilisearch:7700 DATA_DIR: /data redis: image: redis:7.2-alpine restart: unless-stopped volumes: - redis:/data chrome: image: gcr.io/zenika-hub/alpine-chrome:123 restart: unless-stopped command: - --no-sandbox - --disable-gpu - --disable-dev-shm-usage - --remote-debugging-address=0.0.0.0 - --remote-debugging-port=9222 - --hide-scrollbars meilisearch: image: getmeili/meilisearch:v1.6 restart: unless-stopped env_file: - .env environment: MEILI_NO_ANALYTICS: "true" volumes: - meilisearch:/meili_data workers: image: ghcr.io/hoarder-app/hoarder-workers:${HOARDER_VERSION:-release} restart: unless-stopped volumes: - /home/geppetto/docker/hoarder/data:/data env_file: - .env environment: REDIS_HOST: redis MEILI_ADDR: http://meilisearch:7700 BROWSER_WEB_URL: http://chrome:9222 DATA_DIR: /data OLLAMA_BASE_URL: http://host.docker.internal:11434 depends_on: web: condition: service_started volumes: redis: meilisearch: data: ``` this is my .env file: ``` HOARDER_VERSION=release NEXTAUTH_SECRET=*********** MEILI_MASTER_KEY=*********** NEXTAUTH_URL=http://localhost:3000 OLLAMA_BASE_URL=http://host.docker.internal:11434 INFERENCE_TEXT_MODEL=llama3 INFERENCE_IMAGE_MODEL=llava ``` and this is the log of `docker logs hoarder-workers-1`: ``` 2024-07-10T16:19:40.177Z info: [Crawler][64] Will crawl "https://fumettologica.it/2023/02/fumettogame-fumetto-gioco/" for link with id "efe732lxi4p9fhhjvukzcbz7" 2024-07-10T16:19:40.178Z info: [Crawler][64] Attempting to determine the content-type for the url https://fumettologica.it/2023/02/fumettogame-fumetto-gioco/ 2024-07-10T16:19:40.185Z info: [inference][55] Starting an inference job for bookmark with id "e8gi4ma59qoz5js8mpmkj0q8" 2024-07-10T16:19:40.188Z info: [search][72] Attempting to index bookmark with id e8gi4ma59qoz5js8mpmkj0q8 ... 2024-07-10T16:19:40.201Z error: [inference][55] inference job failed: TypeError: fetch failed 2024-07-10T16:19:40.242Z info: [Crawler][64] Content-type for the url https://fumettologica.it/2023/02/fumettogame-fumetto-gioco/ is "text/html; charset=UTF-8" 2024-07-10T16:19:40.259Z info: [search][72] Completed successfully ``` I tried to review previous issues on the theme (like [this one](https://github.com/hoarder-app/hoarder/issues/185)), but I am absolutely not a programmer, so I failed and do not know how to proceed. Any help would be appreciated :-)
kerem closed this issue 2026-03-02 11:47:31 +03:00
Author
Owner

@kamtschatka commented on GitHub (Jul 10, 2024):

I am by no means an expert, but a quick google search shows that "host.docker.internal" works only on windows and mac.
I'd try the real ip address, or maybe localhost also works.

<!-- gh-comment-id:2221230178 --> @kamtschatka commented on GitHub (Jul 10, 2024): I am by no means an expert, but a quick google search shows that "host.docker.internal" works only on [windows and mac](https://stackoverflow.com/questions/48546124/what-is-the-linux-equivalent-of-host-docker-internal). I'd try the real ip address, or maybe localhost also works.
Author
Owner

@f-mc2 commented on GitHub (Jul 11, 2024):

I am by no means an expert, but a quick google search shows that "host.docker.internal" works only on windows and mac. I'd try the real ip address, or maybe localhost also works.

Thank you very much! It was precisely the hint I needed to solve the problem. Here is what I did (I think it is a suboptimal solution, and I will be glad to know that someone has a better one).

First of all, to be able to use host.docker.internal in Linux, I had to add the line

    extra_hosts:
      - "host.docker.internal:172.20.0.1"

to the worker part of the docker-compose file, and OLLAMA_BASE_URL=http://172.20.0.1:11434 in the .enf file. The address 172.0.0.1 is the gateway of the docker network associated with the services in the docker-compose file.

Then, I had to make ollama listen on all local interfaces following this post. Finally, I had to add a firewall rule to allow docker to connect to 172.20.0.1:11434 (I did it brutally by adding accepting all incoming connections at 172.20.0.1:11434, ignoring completely how much of a security risk it is).

Since I am not an expert and I do not feel quite confident about the solution I presented, I think I'll wait a little bit to see if someone with more experience has something to comment before closing the issue.

<!-- gh-comment-id:2222387547 --> @f-mc2 commented on GitHub (Jul 11, 2024): > I am by no means an expert, but a quick google search shows that "host.docker.internal" works only on [windows and mac](https://stackoverflow.com/questions/48546124/what-is-the-linux-equivalent-of-host-docker-internal). I'd try the real ip address, or maybe localhost also works. Thank you very much! It was precisely the hint I needed to solve the problem. Here is what I did (I think it is a suboptimal solution, and I will be glad to know that someone has a better one). First of all, to be able to use `host.docker.internal` in Linux, I had to add the line ``` extra_hosts: - "host.docker.internal:172.20.0.1" ``` to the worker part of the docker-compose file, and `OLLAMA_BASE_URL=http://172.20.0.1:11434` in the .enf file. The address `172.0.0.1` is the gateway of the docker network associated with the services in the docker-compose file. Then, I had to make ollama listen on all local interfaces following [this post](https://github.com/ollama/ollama/issues/703#issuecomment-1951444576). Finally, I had to add a firewall rule to allow docker to connect to `172.20.0.1:11434` (I did it brutally by adding accepting all incoming connections at `172.20.0.1:11434`, ignoring completely how much of a security risk it is). Since I am not an expert and I do not feel quite confident about the solution I presented, I think I'll wait a little bit to see if someone with more experience has something to comment before closing the issue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#193
No description provided.