Relax a hardened default for one service

Find the hardened default that stops an image, and override only that field for only that service.

Read as MarkdownEdit on GitHub

Prerequisites

  • A service in yoink.yaml that fails with the hardened defaults.
  • The Security defaults table, for the opt-out of each field.

Find the default to override

Deploy with the defaults

Deploy the service with no overrides in run.options.

Read the logs

yoink logs <svc>

A container that cannot run with a default stops quickly.

Override one field

If the logs show a “permission denied” failure, override only the field that causes it. If the app works, do not add an override.

Deploy again

Run yoink up. Make sure that the container starts and that its healthcheck passes.

Add one capability again

Caddy must bind :80 and :443. Add only NET_BIND_SERVICE.

# caddy needs to bind :80/:443 — re-add NET_BIND_SERVICE only.
- name: caddy
  run:
    options:
      cap_drop: [ALL]
      cap_add:  [NET_BIND_SERVICE]
      cpus: "0.5"
      memory: "64Mi"

Make the rootfs writable

The image of pgadmin writes to its rootfs at startup. Set only read_only: false.

# pgadmin's image scribbles all over its rootfs at startup — back out
# of read_only, keep the rest of the hardened defaults.
- name: pgadmin
  run:
    options:
      read_only: false
      cpus: "1"
      memory: "256Mi"

Give a read-only service scratch space

If the app only needs /tmp, /run, or a cache directory, keep read_only: true. Add a tmpfs: entry for each directory. The data in a tmpfs: does not persist.

run:
  options:
    read_only: true
    tmpfs:
      /tmp: "size=64m,mode=1777"
      /var/cache/app: "size=128m,mode=0755"

Run an image as root with a writable /etc

Use this config only for an image with legacy code that needs root and a writable /etc.

# Image with stubborn legacy code that needs root + writable /etc.
- name: legacy-thing
  run:
    options:
      user: "0:0"
      read_only: false
      cap_drop: []
      security_opt: []

Add a host device

List only the device nodes that the service needs. This is narrower than privileged mode.

# Hardware passthrough — opt into specific device nodes only,
# not the whole privileged blast radius. See below.
- name: jellyfin
  run:
    options:
      user: "0:0"        # most media images need root for HW access
      devices:
        - /dev/dri       # Intel/AMD VAAPI — read+write+mknod default

Pass host devices into a container has the config for the other device types.

Make sure that the override is in effect

In the TUI, press i on the container row. The “security & limits” section shows the effective security profile of the container.

See also

Type a flag, a config field, or a task.