This Docker Compose configuration sets up two Ollama services using the ollama/ollama image.
- Purpose: Runs the Ollama API server exposed on port
11434. - Health Check: Includes a health check to ensure the service is running.
- Resources: Allocates 8.5GiB of memory.
- Restart Policy: Restarts unless stopped.
- Purpose: Pulls Llama models (like
llama3.2,llama2, andnomic-embed-text) on container startup. - Dependencies: Depends on the main Ollama service (
ollama-cpu) to ensure models are downloaded before starting. - Restart Policy: Does not restart after execution.
- Volumes: Both services use a shared volume (
ollama_storage) to store data. - Networks: The services are connected via a custom network (
demo). - Profiles: Both services are configured for CPU usage.
This configuration is designed for setting up Ollama in a CPU environment, initializing models on startup, and serving them via the API.
To start the services with the CPU profile, use the following command:
docker-compose --profile cpu up