Introduction
Docling is a powerful document parsing, conversion, and chunking solution that supports OCR, layout analysis, and table extraction. While the docling-serve Docker image provides a convenient REST API, it does not automatically download required models on first use—unlike the standalone version.
This article explains how to preload models into a custom Docker image to ensure smooth deployment without runtime delays.
Why Preload Models?
By default, Docling downloads models (e.g., layout, tableformer) when first needed. However, in containerized environments:
- No persistent storage → Models vanish when the container restarts.
- Network dependency → First-time usage requires internet access.
- Performance overhead → Downloads slow down initial requests.
Preloading models into the image avoids these issues.
Step-by-Step: Building a Custom Image
Create a Dockerfile
Extend the official docling-serve image and download models to a known path (models):
FROM quay.io/docling-project/docling-serve
RUN docling-tools models download layout tableformer -o /models
Note: Replace layout and tableformer with your required models.
Build the Image
docker build -t my-docling-serve .
Configure Deployment
.env File
Set the artifacts path to match the preloaded models:
DOCLING_SERVE_ENABLE_UI=true
DOCLING_ARTIFACTS_PATH=models
docker-compose.yml
services:
docling:
image: my-docling-serve:latest
container_name: docling-serve
restart: unless-stopped
ports:
- "5001:5001"
env_file:
- .env
Start the Container
docker compose up -d
Accessing the API
Once running, the service exposes:
- Base URL:
http://127.0.0.1:5001/ - OpenAPI Docs:
http://127.0.0.1:5001/docs - Test UI (if enabled):
http://127.0.0.1:5001/ui/