Background
SonarCloud flags the runtime stage of the Dockerfile as running with root as the default user (security hotspot, category: permission, MEDIUM).
Dockerfile:24 — This image might run with "root" as the default user. Make sure it is safe here.
Why this needs care (not a quick fix)
Ofelia communicates with the Docker socket (/var/run/docker.sock) to schedule and run jobs in containers. Adding a non-root USER to the image requires careful handling:
- The non-root user must be a member of a group whose GID matches the host's
docker socket group, which varies per host — a hardcoded GID will break socket access on many systems.
- May need a documented
--group-add / compose group_add runtime requirement.
- Needs verification that all job types (run, exec, local, compose) still work after the change.
Because socket access is environment-dependent, this is a non-trivial hardening task that needs design + testing across deployment scenarios, not a one-line USER directive.
Acceptance criteria
References
Background
SonarCloud flags the runtime stage of the
Dockerfileas running withrootas the default user (security hotspot, category: permission, MEDIUM).Why this needs care (not a quick fix)
Ofelia communicates with the Docker socket (
/var/run/docker.sock) to schedule and run jobs in containers. Adding a non-rootUSERto the image requires careful handling:dockersocket group, which varies per host — a hardcoded GID will break socket access on many systems.--group-add/ composegroup_addruntime requirement.Because socket access is environment-dependent, this is a non-trivial hardening task that needs design + testing across deployment scenarios, not a one-line
USERdirective.Acceptance criteria
Dockerfilepermission resolvedReferences