do we have official ollama docker image < 1 GB #6547

Closed
opened 2025-11-12 13:37:19 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @babu-kandyala on GitHub (Mar 25, 2025).

What is the issue?

i need to build custom ollama image from modelfile using ollama base image and looking for slim/lite < 1 GB or around 1 GB

Relevant log output


OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @babu-kandyala on GitHub (Mar 25, 2025). ### What is the issue? i need to build custom ollama image from modelfile using ollama base image and looking for slim/lite < 1 GB or around 1 GB ### Relevant log output ```shell ``` ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the
bug
label 2025-11-12 13:37:19 -06:00
Author
Owner

@ngxson commented on GitHub (Mar 25, 2025):

IIRC llama.cpp build size can be reduced by excluding flash attention kernels, but you will get lower performance

@ngxson commented on GitHub (Mar 25, 2025): IIRC llama.cpp build size can be reduced by excluding flash attention kernels, but you will get lower performance
Author
Owner

@rick-github commented on GitHub (Mar 25, 2025):

The bulk of the contents is the CUDA libraries.

$ docker run --rm --entrypoint bash ollama/ollama -c 'du -sxmc /'
3302    /
3302    total
$ docker run --rm --entrypoint bash ollama/ollama -c 'du -sxmc /usr/lib/ollama/*'
1150    /usr/lib/ollama/cuda_v11
2034    /usr/lib/ollama/cuda_v12
1       /usr/lib/ollama/libggml-base.so
1       /usr/lib/ollama/libggml-cpu-alderlake.so
1       /usr/lib/ollama/libggml-cpu-haswell.so
1       /usr/lib/ollama/libggml-cpu-icelake.so
1       /usr/lib/ollama/libggml-cpu-sandybridge.so
1       /usr/lib/ollama/libggml-cpu-skylakex.so
3187    total

You could add RUN rm -rf /usr/lib/ollama/cuda_v12 to the end of the Dockerfile and free 2G, final image would be just over 1G.

@rick-github commented on GitHub (Mar 25, 2025): The bulk of the contents is the CUDA libraries. ```console $ docker run --rm --entrypoint bash ollama/ollama -c 'du -sxmc /' 3302 / 3302 total $ docker run --rm --entrypoint bash ollama/ollama -c 'du -sxmc /usr/lib/ollama/*' 1150 /usr/lib/ollama/cuda_v11 2034 /usr/lib/ollama/cuda_v12 1 /usr/lib/ollama/libggml-base.so 1 /usr/lib/ollama/libggml-cpu-alderlake.so 1 /usr/lib/ollama/libggml-cpu-haswell.so 1 /usr/lib/ollama/libggml-cpu-icelake.so 1 /usr/lib/ollama/libggml-cpu-sandybridge.so 1 /usr/lib/ollama/libggml-cpu-skylakex.so 3187 total ``` You could add `RUN rm -rf /usr/lib/ollama/cuda_v12` to the end of the Dockerfile and free 2G, final image would be just over 1G.
Author
Owner

@rick-github commented on GitHub (Mar 25, 2025):

Actually, RUN rm will just create another layer. The files have to be excluded while building the image, not removed afterwards.

FROM ollama/ollama as base

FROM ubuntu:20.04
RUN apt-get update \
    && apt-get install -y ca-certificates \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*
COPY --from=base /bin /usr/bin
COPY --from=base /lib/ollama/*.so /usr/lib/ollama/
COPY --from=base /lib/ollama/cuda_v11 /usr/lib/ollama/cuda_v11
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENV NVIDIA_VISIBLE_DEVICES=all
ENV OLLAMA_HOST=0.0.0.0:11434
EXPOSE 11434
ENTRYPOINT ["/bin/ollama"]
CMD ["serve"]
$ docker build -f Dockerfile -t ollama-v11 .
$ docker image ls ollama-v11
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
ollama-v11   latest    71fece84b276   4 minutes ago   1.34GB
@rick-github commented on GitHub (Mar 25, 2025): Actually, `RUN rm` will just create another layer. The files have to be excluded while building the image, not removed afterwards. ```dockerfile FROM ollama/ollama as base FROM ubuntu:20.04 RUN apt-get update \ && apt-get install -y ca-certificates \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* COPY --from=base /bin /usr/bin COPY --from=base /lib/ollama/*.so /usr/lib/ollama/ COPY --from=base /lib/ollama/cuda_v11 /usr/lib/ollama/cuda_v11 ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64 ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility ENV NVIDIA_VISIBLE_DEVICES=all ENV OLLAMA_HOST=0.0.0.0:11434 EXPOSE 11434 ENTRYPOINT ["/bin/ollama"] CMD ["serve"] ``` ```console $ docker build -f Dockerfile -t ollama-v11 . $ docker image ls ollama-v11 REPOSITORY TAG IMAGE ID CREATED SIZE ollama-v11 latest 71fece84b276 4 minutes ago 1.34GB ```
Author
Owner

@babu-kandyala commented on GitHub (Mar 25, 2025):

Thank you ! and also i need to create custom ollama model using the same ollama image, as per #9888 . please help

@babu-kandyala commented on GitHub (Mar 25, 2025): Thank you ! and also i need to create custom ollama model using the same ollama image, as per #9888 . please help
Author
Owner

@rick-github commented on GitHub (Mar 25, 2025):

Add the Zscaler certificate to your image as shown in https://github.com/ollama/ollama/issues/9391#issuecomment-2698816430.

@rick-github commented on GitHub (Mar 25, 2025): Add the Zscaler certificate to your image as shown in https://github.com/ollama/ollama/issues/9391#issuecomment-2698816430.
Author
Owner

@babu-kandyala commented on GitHub (Mar 25, 2025):

not #9391 , i need to create custom model and make it up & running with in below dockerfile.
for Eg: ollama create custom_model -f Modelfile as per #9888

FROM ollama/ollama as base

FROM ubuntu:20.04
RUN apt-get update
&& apt-get install -y ca-certificates
&& apt-get clean
&& rm -rf /var/lib/apt/lists/*
COPY --from=base /bin /usr/bin
COPY --from=base /lib/ollama/*.so /usr/lib/ollama/
COPY --from=base /lib/ollama/cuda_v11 /usr/lib/ollama/cuda_v11
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENV NVIDIA_VISIBLE_DEVICES=all
ENV OLLAMA_HOST=0.0.0.0:11434
EXPOSE 11434
ENTRYPOINT ["/bin/ollama"]
CMD ["serve"]

@babu-kandyala commented on GitHub (Mar 25, 2025): not #9391 , i need to create custom model and make it up & running with in below dockerfile. for Eg: ollama create custom_model -f Modelfile as per #9888 FROM ollama/ollama as base FROM ubuntu:20.04 RUN apt-get update \ && apt-get install -y ca-certificates \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* COPY --from=base /bin /usr/bin COPY --from=base /lib/ollama/*.so /usr/lib/ollama/ COPY --from=base /lib/ollama/cuda_v11 /usr/lib/ollama/cuda_v11 ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64 ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility ENV NVIDIA_VISIBLE_DEVICES=all ENV OLLAMA_HOST=0.0.0.0:11434 EXPOSE 11434 ENTRYPOINT ["/bin/ollama"] CMD ["serve"]
Author
Owner

@rick-github commented on GitHub (Mar 25, 2025):

#9888 is because the model pull failed. You fix that by adding the Zscaler certificate to your image as shown in https://github.com/ollama/ollama/issues/9391#issuecomment-2698816430. Then you add your model as shown in https://github.com/ollama/ollama/issues/9888#issuecomment-2736224280.

@rick-github commented on GitHub (Mar 25, 2025): #9888 is because the model pull failed. You fix that by adding the Zscaler certificate to your image as shown in https://github.com/ollama/ollama/issues/9391#issuecomment-2698816430. Then you add your model as shown in https://github.com/ollama/ollama/issues/9888#issuecomment-2736224280.
Author
Owner

@babu-kandyala commented on GitHub (Mar 25, 2025):

will try it out, and update if any issue

@babu-kandyala commented on GitHub (Mar 25, 2025): will try it out, and update if any issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama-ollama#6547
No description provided.