Init Container
ELI5 — The Vibe Check
An init container runs before your main app container starts. It handles setup tasks like running database migrations, fetching config files, or waiting for dependencies to be ready. It's the opening act that makes sure the stage is set before the main performer comes on.
Real Talk
Init containers are specialized containers in Kubernetes that run to completion before app containers start. They execute initialization logic like schema migrations, config generation, dependency checks, or secret fetching. They run sequentially, must succeed, and share volumes with app containers. If an init container fails, the pod restarts.
Show Me The Code
initContainers:
- name: run-migrations
image: myapp:latest
command: ['python', 'manage.py', 'migrate']
- name: wait-for-db
image: busybox
command: ['sh', '-c', 'until nc -z db 5432; do sleep 1; done']
When You'll Hear This
"The init container runs migrations before the app starts accepting traffic." / "Use an init container to wait for the database to be available."
Related Terms
Container
A container is a running instance of a Docker image — it's the lunchbox you made and actually opened to eat from.
Kubernetes
Kubernetes is a robot manager for your containers.
Migration
A migration is a versioned script that modifies your database schema — adding a column, creating a table, changing a type.
Sidecar Pattern
The sidecar pattern attaches a helper container to your main app, like a motorcycle sidecar.