Skip to Content
IoT App DevelopmentDocker & Compose

Docker & Compose

IronFlock apps are packaged as Docker images. The Dockerfile defines the runtime environment for your application code.

Dockerfile

Every app requires a Dockerfile in the root folder. This file configures a Linux environment for your app, starting from a base image:

FROM python:3.11-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . CMD ["python", "main.py"]

Refer to the official Dockerfile documentation for the full syntax reference.

Multi-Architecture Support

To target different device architectures, add architecture-specific Dockerfiles:

FileArchitectureExample Devices
DockerfileDefault (used as fallback)Any
Dockerfile.armv7ARMv7Raspberry Pi 3/4 (32-bit)
Dockerfile.arm64ARM64NVIDIA Jetson, RPi 4/5 (64-bit)
Dockerfile.amd64AMD64Industrial PCs, Intel NUCs

When building a release, IronFlock selects the most specific Dockerfile for each target architecture. If no architecture-specific file exists, the default Dockerfile is used.

Docker Compose

For apps with multiple services (e.g., a web server + a database + a worker), use Docker Compose:

# docker-compose.yml version: "3" services: app: build: . volumes: - /data:/data - /shared:/shared ports: - "5000:5000" restart: unless-stopped redis: image: redis:7-alpine restart: unless-stopped

Place the docker-compose.yml in the root folder instead of (or alongside) a Dockerfile. When users start or stop the app on their devices, the entire Compose stack is managed as a unit.

Docker Compose gives you more control over:

  • Volume mounts and data persistence
  • Service networking
  • Resource limits
  • Multi-container architectures

Best Practices

  • Keep images small — Use -slim or -alpine base images to reduce download times on constrained devices.
  • Pin versions — Use specific version tags (python:3.11-slim) instead of latest for reproducible builds.
  • Cache layers — Copy dependency files before application code to leverage Docker layer caching.
  • Use .dockerignore — Exclude unnecessary files (docs, tests, .git) from the build context.
Last updated on