The snippet library.
Small, practical examples. Search by task or narrow things down below.
Read a secret from a mounted file
Docker / Compose: Compose secrets make a file available under /run/secrets.
Docker / Compose✓ Tested
Run a Compose service as a non-root user
Docker / Compose: user overrides the image’s default identity.
Docker / Compose✓ Tested
Set a Compose service’s working directory
Docker / Compose: working_dir changes where the container command starts.
Docker / Compose✓ Tested
Set a service’s open-file limit
Docker / Compose: The ulimits mapping defines soft and hard resource limits.
Docker / Compose✓ Tested
Set no-new-privileges in Compose
Docker / Compose: security_opt configures the process privilege restriction.
Docker / Compose✓ Tested
Supply a default for an unset Compose variable
Docker / Compose: The default interpolation form supplies a value when the variable is absent or empty.
Docker / Compose✓ Tested
Supply a non-secret configuration file
Docker / Compose: A Compose config mounts a declared file into the service.
Docker / Compose✓ Tested
Wait for a healthy Compose dependency
Docker / Compose: The service_healthy dependency condition waits for the dependency’s health command to succeed.
Docker / Compose✓ Tested