An init container is a Kubernetes container that runs to completion before the main containers in a Pod start. It prepares conditions the application needs without remaining active afterward. section 8.4.2
Preparing a PostgreSQL volume
A StatefulSet mounts a new volume containing lost+found. An Alpine init container mounts the same volume, runs sh -c "rm -rf /mnt/lost+found", and exits before PostgreSQL starts. section 8.4.2
Listing 8.19 StatefulSet for Postgres, part 3
...
spec:
...
template:
metadata:
labels:
app: postgres
spec:
initContainers:
- name: delete-lost-found
image: alpine:latest
command: ["sh", "-c", "rm -rf /mnt/lost+found"]
volumeMounts:
- name: db-vol
mountPath: /mnt
volumeClaimTemplates:
- metadata:
name: db-vol
spec:
...
Inspect the StatefulSet configuration showing the init container, Alpine image, cleanup command, and shared volume mount. section 8.4.2

