Add USER instruction

Apache 2.0

Adds a USER instruction to run the container as a non-root user (CIS Docker Benchmark 4.1). By default, adds to the final stage only and skips if a USER instruction already exists.

org.openrewrite.docker.AddUserInstruction

Required

The username to run as.

Optional

The group name. If specified, the USER instruction will be USER user:group.

Only add the USER instruction to this build stage. If null, adds to the final stage only.

skipIfUserExistsBoolean

If true (default), skip adding USER if the stage already has a USER instruction. If false, always add the USER instruction at the end of the stage.

mod run . --recipe=org.openrewrite.docker.AddUserInstruction \ -P userName=appuser

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.