Docker Deployment Reference
Production best practices, troubleshooting, and security hardening for kdeps Docker deployments. See Docker Deployment for the core packaging and build workflow.
Production Best Practices
Use Specific Tags
# Good
kdeps bundle build app.kdeps --tag myregistry/myagent:1.0.0
# Avoid
kdeps bundle build app.kdeps --tag myregistry/myagent:latestSet Resource Limits
# docker-compose.yml
services:
myagent:
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2GUse Secrets
# Create secret
echo "my-api-key" | docker secret create api_key -
# Use in container
docker service create \
--secret api_key \
myregistry/myagent:latestEnable Logging
# docker-compose.yml
services:
myagent:
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"Network Security
# docker-compose.yml
services:
myagent:
networks:
- internal
ports:
- "127.0.0.1:16395:16395" # Only local access
networks:
internal:
internal: trueSecurity Hardening
Generated images run as the unprivileged kdeps user, including Ollama-backed images. Ollama models are stored under /app/.ollama/models.
Do not put KDEPS_API_AUTH_TOKEN, KDEPS_MANAGEMENT_TOKEN, or other secret-like keys in agentSettings.env - Docker build fails if you try. Pass auth tokens at container runtime with -e or secrets mounts.
Before exposing a container externally, add these fields to workflow.yaml:
# workflow.yaml
settings:
certFile: "/run/secrets/server.crt" # mount cert into container; enables HTTPS
keyFile: "/run/secrets/server.key"
apiServer:
# auth token (required): KDEPS_API_AUTH_TOKEN env var or api_auth_token in ~/.kdeps/config.yaml
rateLimit:
requestsPerMinute: 60 # sustained per-IP rate
burst: 10 # burst allowance above the sustained rate
maxBodyBytes: 1048576 # 1 MB cap on request body size
maxConcurrent: 50 # excess requests get 503 immediatelySee Security for the full reference.
Troubleshooting
Build Fails
# Show detailed output
kdeps bundle build app.kdeps --show-dockerfile
# Check Docker daemon
docker infoImage Too Large
- Use
alpinebase OS - Remove unnecessary packages
- Use optimized templates (automatic)
- Avoid
offlineModeunless needed
Model Download Slow
# Llamafiles are cached in ~/.kdeps/models/ and baked into the image at build
# time automatically. For the ollama backend, pre-pull models before build:
ollama pull llama3.2:1b
# Or use offline mode
offlineMode: trueCheck Workflow Status
curl -H "Authorization: Bearer $KDEPS_MANAGEMENT_TOKEN" \
http://localhost:16395/_kdeps/status{
"status": "ok",
"workflow": {
"name": "my-agent",
"version": "2.0.0",
"description": "My AI agent",
"resources": 3
}
}Docker Compose with Management API
# docker-compose.yml
services:
myagent:
image: myregistry/myagent:latest
ports:
- "16395:16395"
environment:
- KDEPS_API_AUTH_TOKEN=${KDEPS_API_AUTH_TOKEN}
- KDEPS_MANAGEMENT_TOKEN=${KDEPS_MANAGEMENT_TOKEN}
restart: unless-stoppedSet tokens in your .env file (never commit this file):
# .env
KDEPS_API_AUTH_TOKEN=api-secret
KDEPS_MANAGEMENT_TOKEN=mysecretFor the full management API reference see Management API.
See Also
- Docker Deployment - Core packaging and build workflow
- Kubernetes Deployment - Cluster deployment
- Management API - Live workflow updates without rebuilding
Let's Encrypt
For custom domains without mounting PEM secrets, set settings.letsEncrypt.domain and publish ports 80/443. See TLS and HTTPS (Custom Domains) and Security — TLS.
