Developer tools · Docker run to Docker compose converter
--privileged, --cap-add and --device: what they mean in a Compose file
· Why it matters
docker compose security
One flag turns most of Docker's isolation off. This post explains what --privileged actually grants, the narrower alternatives, and how they look under privileged:, cap_add: and devices: after conversion.
The forum said add --privileged — the container works now and the isolation that made containers attractive is largely gone
The forum said add --privileged — the container works now and the isolation that made containers attractive is largely gone. Evidence: --privileged becomes privileged true without a safety endorsement. Reproduce least privilege with disposable literals. Pair each source occurrence with privileged capabilities devices; reserve host confinement and access for destination review.
The security incident also reveals that A separate security incident boundary is that --device is recognized but warned and omitted as host-dependent. Evidence: --device is recognized but warned and omitted as host-dependent. This least privilege constraint is a stopping point. Inspect privileged capabilities devices without manufacturing behavior, then document a host check for host confinement and access.
What --privileged does — all capabilities, access to all devices and relaxed seccomp and AppArmor confinement
What --privileged does — all capabilities, access to all devices and relaxed seccomp and AppArmor confinement. Evidence: host confinement effects cannot be enumerated from command text. Trace least privilege tokens into privileged capabilities devices. Separate ordered values from last-value fields; host confinement and access is outside collection.
A related security mechanism boundary is that A separate security grammar boundary is that required Zigbee access cannot be inferred from a former privileged command. Evidence: required Zigbee access cannot be inferred from a former privileged command. Use this least privilege fact to predict one member or scalar in privileged capabilities devices. Check warnings before deciding anything about host confinement and access.
Capabilities instead — cap_add: with NET_ADMIN, SYS_TIME or others as the narrow version, and cap_drop: ALL as the baseline
Capabilities instead — cap_add: with NET_ADMIN, SYS_TIME or others as the narrow version, and cap_drop: ALL as the baseline. Evidence: --cap-add and --cap-drop become explicit ordered lists. Judge least privilege serialization from its model. Quoting in privileged capabilities devices protects types but gives no operational proof for host confinement and access.
The second security serialization observation is A separate security output boundary is that a visible privileged key supports review while warnings preserve gaps. Evidence: a visible privileged key supports review while warnings preserve gaps. This least privilege output separates settings from unavailable context. Keep privileged capabilities devices reviewable and check host confinement and access independently.
--device is recognised but deliberately not converted; add a host-specific devices list manually
Devices instead — --device /dev/ttyUSB0 becoming devices:, the usual real reason people reached for --privileged. Evidence: --device is recognized but warned and omitted as host-dependent; --device is recognised but deliberately not converted; add a host-specific devices list manually. Stop at the least privilege exception instead of guessing. Any addition near privileged capabilities devices needs a deployment-specific reason tied to host confinement and access.
Another security exception constraint is that for this security section keep the original for this security section command and warnings for this security section beside this candidate file. Evidence: the repository gives no broader runtime or historical proof. Keep the original least privilege command beside warnings. The comparison shows what privileged capabilities devices contains and which host confinement and access decision remains manual.
A de-privileging edit requires operator judgement because this converter cannot infer required devices or capabilities
Worked example: de-privileging a Zigbee bridge command — replacing --privileged with a devices entry and a single capability. Evidence: required Zigbee access cannot be inferred from a former privileged command; A de-privileging edit requires operator judgement because this converter cannot infer required devices or capabilities. Build the least privilege example from synthetic names. Make every privileged capabilities devices item traceable without exposing production host confinement and access details.
The same security example sample demonstrates that for this security section keep the original for this security section command and warnings for this security section beside this candidate file. The paired least privilege fact should be visible in privileged capabilities devices. Record that line and avoid assumptions about host confinement and access.
Reading the converted YAML as a review — privileged: true stands out in a diff in a way a flag in a shell line does not
Reading the converted YAML as a review — privileged: true stands out in a diff in a way a flag in a shell line does not. Translate the least privilege consequence into one observable privileged capabilities devices difference. Docker owns the later host confinement and access verdict.
The security consequence implementation also shows A separate security effect boundary is that --privileged becomes privileged true without a safety endorsement. Split least privilege responsibilities: conversion writes privileged capabilities devices, the repository removes secrets, and operators validate host confinement and access.
What this does not cover — GPU access, custom seccomp profiles and Kubernetes security contexts
What this does not cover — GPU access, custom seccomp profiles and Kubernetes security contexts. Evidence: GPU reservation and custom profiles are not generated. Limit least privilege scope to privileged capabilities devices branches shown here. Neighboring forms and defaults cannot answer host confinement and access questions.
One more security scope limit follows from A separate security limit boundary is that host confinement effects cannot be enumerated from command text. Treat this least privilege boundary as an exclusion. Prefer accurate privileged capabilities devices over guesses about host confinement and access.
Privilege is visible when mapped, but unsupported device access remains a warning rather than a generated key
Takeaway: privilege should be explicit and minimal — and the converter makes it visible as keys you can question. Evidence: least privilege requires human design beyond conversion; Privilege is visible when mapped, but unsupported device access remains a warning rather than a generated key. Audit least privilege as source option, model field, privileged capabilities devices line and warning. Remove secrets before checking host confinement and access.
Finally, the security takeaway source confirms keep the original command for this security section and warnings beside for this security section this candidate file that security takeaway conclusion improves auditability for this security section without promising equivalence shell for this security section parsing remains outside the security takeaway guarantee. Close least privilege narrowly: privileged capabilities devices is a candidate; host confinement and access and shell equivalence are not guarantees.