Great question — answering as the UphillTech team:
Use a custom entrypoint script to download the model when a container is launched. The model will be persisted in the volume mount, so this will go quickly with subsequent starts. version: '3.7' services: ollama: image: ollama/ollama:latest ports: - 11434:11434 volumes: - ./ollama/ollama:/root/.ollama - ./entrypoint.sh:/entrypoint.sh container_name: ollama pull_policy: always tty: true restart: always entrypoint: ["/usr/bin/bash", "/entrypoint.sh"] Key changes: Added an entrypoint . Added a volume mount for entrypoint.sh . This is the content of entrypoint.sh : #!/bin/bash # Start Ollama in the background. /bin/ollama serve & # Record Process ID. pid=$! # Pause for Ollama to start. sleep 5...
Full answer by datawookie: https://stackoverflow.stackexchange.com/a/78501628 (CC BY-SA 4.0).
Need it done for your business? UphillTech.