The snippet library.
Small, practical examples. Search by task or narrow things down below.
Choose the signal used for graceful stopping
Docker / Compose: The configured stop signal is recorded in container metadata.
Docker / Compose✓ Tested
Configure bounded retries after a failure
Docker / Compose: on-failure with a count limits automatic restart attempts.
Docker / Compose✓ Tested
Confirm the root filesystem rejects writes
Docker / Compose: A read-only root prevents creating files outside writable mounts.
Docker / Compose✓ Tested
Drop all optional Linux capabilities
Docker / Compose: The effective capability mask becomes zero after cap-drop ALL.
Docker / Compose✓ Tested
Insert Docker’s small init process
Docker / Compose: The init option adds a PID 1 process that reaps children and forwards signals.
Docker / Compose✓ Tested
Limit the number of container processes
Docker / Compose: The pids-limit setting caps the container’s process count.
Docker / Compose✓ Tested
Prevent gaining privileges through exec
Docker / Compose: The no-new-privileges flag is visible in process status.
Docker / Compose✓ Tested
Set and inspect a fractional CPU limit
Docker / Compose: The cpus option records a limit in units of one billion NanoCPUs.
Docker / Compose✓ Tested
Set the open-file limit for a process
Docker / Compose: The nofile ulimit sets soft and hard file descriptor limits.
Docker / Compose✓ Tested
Wait for an actual container health check
Docker / Compose: Health reports readiness independently from process startup.
Docker / Compose✓ Tested