π³ Docker Integration
Containerize FlowyML pipelines with optimized Docker images, multi-stage builds, and registry management.
π¦ Multi-Stage Builds π·οΈ Registry Push β‘ Optimized Images
π³ Docker Integration
What you'll learn
How to run pipelines in isolated Docker containers β eliminate "it works on my machine" bugs forever.
Containerize your pipelines for reproducible execution anywhere β from a laptop to a Kubernetes cluster.
Why Docker?
| Feature | Benefit |
|---|---|
| Isolation | Each step runs in a clean environment |
| Reproducibility | Identical code and dependencies in dev, staging, prod |
| Portability | Move from local Docker to K8s or cloud without code changes |
| Dependency Control | No conflicts between different step requirements |
π³ Running on Docker
FlowyML can automatically build and run your steps in Docker containers:
from flowyml.integrations.docker import DockerOrchestrator
pipeline.run(
orchestrator=DockerOrchestrator(
image="python:3.11-slim", # Base image
install_deps=True, # Auto-install requirements.txt
)
)
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
image |
str |
python:3.11-slim |
Base Docker image |
install_deps |
bool |
True |
Auto-install requirements.txt |
dockerfile |
str |
None |
Path to custom Dockerfile |
build_context |
str |
"." |
Docker build context |
volumes |
dict |
{} |
Volume mounts (host:container) |
env_vars |
dict |
{} |
Environment variables |
π Custom Dockerfiles
For complex dependencies, provide your own Dockerfile:
Example Dockerfile
FROM python:3.11-slim
# System dependencies
RUN apt-get update && apt-get install -y gcc libgomp1 && rm -rf /var/lib/apt/lists/*
# Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Application code
COPY . /app
WORKDIR /app
π Volume Mounts
Mount local directories into the container for data access:
orchestrator = DockerOrchestrator(
image="python:3.11-slim",
volumes={
"/data/training": "/app/data", # Host β Container
"/models/registry": "/app/models",
},
)
Best Practices
Pin image versions
Use python:3.11.7-slim instead of python:3.11-slim for reproducible builds.
Multi-stage builds
Use multi-stage Dockerfiles to keep images small β build dependencies in one stage, copy only artifacts to the final stage.
GPU support
For GPU steps, use NVIDIA base images (e.g., nvidia/cuda:12.0-runtime) and install nvidia-docker2.
π What's Next?
βΈοΈ Kubernetes Integration
Orchestrate pipelines on Kubernetes with auto-scaling, GPU scheduling, and distributed execution.
π Production Deployment
Scale your containerized pipelines to production-grade infrastructure.