[GH-ISSUE #2160] Add support for fresh initialization and hooks in Docker image #26995

Closed
opened 2026-04-22 03:49:45 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @eddumelendez on GitHub (Jan 23, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2160

It would be nice to improve models pulling and custom model creation when starting with Ollama.

Fresh initialization

Some databases allows to copy .sh and .sql to execute instructions once it is ready. See mysql docs.

Example:

Create ollama.sh

ollama pull llama2

Copy or mount the shell under docker-entrypoint-initollama.d/ollama.sh and once Ollama is up then the model will be pulled automatically.

Hooks

LocalStack offers something more regarding to the Fresh initialization approach through lifecycle stages and hooks and it also provides a nice API to check the status of those hooks.

Example:

Create ollama.sh

ollama pull llama2

Copy or mount the shell under /etc/localstack/init/ready.d/ollama.sh.

Note

LocalStack offers boot, ready, shutdown and start stages but not sure if all of them could have a use case in Ollama.

With this enhancement starting with Ollama will improve experience with Dockerfile, Docker Compose and Testcontainers by mounting or copying files and make the model ready to use. My use case is simple to pull images but it will also help to create custom models.

Originally created by @eddumelendez on GitHub (Jan 23, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2160 It would be nice to improve models pulling and custom model creation when starting with Ollama. # Fresh initialization Some databases allows to copy `.sh` and `.sql` to execute instructions once it is ready. See mysql [docs](https://github.com/docker-library/docs/tree/master/mysql#initializing-a-fresh-instance). Example: Create `ollama.sh` ```sh ollama pull llama2 ``` Copy or mount the shell under `docker-entrypoint-initollama.d/ollama.sh` and once Ollama is up then the model will be pulled automatically. # Hooks LocalStack offers something more regarding to the Fresh initialization approach through [lifecycle stages and hooks](https://docs.localstack.cloud/references/init-hooks/) and it also provides a nice [API to check the status of those hooks](https://docs.localstack.cloud/references/init-hooks/#status-endpoint). Example: Create `ollama.sh` ```sh ollama pull llama2 ``` Copy or mount the shell under `/etc/localstack/init/ready.d/ollama.sh`. > [!NOTE] > LocalStack offers `boot`, `ready`, `shutdown` and `start` stages but not sure if all of them could have a use case in Ollama. With this enhancement starting with Ollama will improve experience with Dockerfile, Docker Compose and Testcontainers by mounting or copying files and make the model ready to use. My use case is simple to pull images but it will also help to create custom models.
Author
Owner

@mxyng commented on GitHub (Mar 11, 2024):

There's currently no plans to support this feature but that might change as the project evolves

<!-- gh-comment-id:1989241298 --> @mxyng commented on GitHub (Mar 11, 2024): There's currently no plans to support this feature but that might change as the project evolves
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#26995