Ollama in Docker pulls models via interactive shell but not via RUN command in the dockerfile

95 Views Asked by At

I have Ollama running in a Docker container that I spun up from the official image. I can successfully pull models in the container via interactive shell by typing commands at the command-line such as:

ollama pull nomic-embed-text

This command pulls in the model: nomic-embed-text.

Now I try to do the same via dockerfile:

FROM ollama/ollama

RUN ollama pull nomic-embed-text

# Expose port 11434
EXPOSE 11434

# Set the entrypoint
ENTRYPOINT ["ollama", "serve"]

and get

Error: could not connect to ollama app, is it running?
------
dockerfile:9
--------------------
   7 |     COPY . .
   8 |     
   9 | >>> RUN ollama pull nomic-embed-text
  10 |     
  11 |     # Expose port 11434
--------------------
ERROR: failed to solve: process "/bin/sh -c ollama pull nomic-embed-text" did not complete successfully: exit code: 1

As far as I know, I am doing the same thing but it works in one place and not another. Any help?

Based on the error message, I updated the dockerfile to launch the ollama service before pulling the model. No change.

FROM ollama/ollama

# Expose port 11434
EXPOSE 11434

RUN ollama serve &
RUN ollama pull nomic-embed-text

It gave same error message.

0

There are 0 best solutions below