Fix SecretsUsedInArgOrEnv: remove ENV ROOT_PASSWORD from Dockerfiles#626
Closed
Fix SecretsUsedInArgOrEnv: remove ENV ROOT_PASSWORD from Dockerfiles#626
Conversation
… support in run.sh Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/547bc2de-e8b4-4cd4-8ef1-f831dd509aaf Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Docker lint warning for ROOT_PASSWORD in Dockerfile
Fix SecretsUsedInArgOrEnv: remove ENV ROOT_PASSWORD from Dockerfiles
Apr 8, 2026
Member
|
@copilot merge from master |
…lint-warning-root-password Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Contributor
Author
Done — merged master into this branch (commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ENV ROOT_PASSWORD="password"in both Dockerfiles bakes a sensitive value into the image — visible viadocker inspectand persistent across all layers — triggering theSecretsUsedInArgOrEnvlint warning.Changes
Dockerfile/Dockerfile-alpine: RemoveENV ROOT_PASSWORD="password", replace with a comment directing users to pass the value at runtimerun.sh: ResolveROOT_PASSWORDat container startup with priority order: Docker secret file → env var → default"password"Runtime usage
docker run -e ROOT_PASSWORD=secret .../run/secrets/root_password"password"viarun.shThe
HEALTHCHECKlines referencing$ROOT_PASSWORDare unaffected — the variable is available at runtime via the above mechanisms.Original prompt
Fix Docker lint warning: SecretsUsedInArgOrEnv for ROOT_PASSWORD
Problem
Both
opendj-packages/opendj-docker/Dockerfileandopendj-packages/opendj-docker/Dockerfile-alpinehaveENV ROOT_PASSWORD="password"on line 11, which triggers the Docker lint warning:Sensitive data baked into an image via
ENVis visible indocker inspectand persists in every image layer.Required Changes
1.
opendj-packages/opendj-docker/Dockerfile(line 11):Remove
ENV ROOT_PASSWORD="password"and replace it with a comment explaining how to pass the password at runtime:2.
opendj-packages/opendj-docker/Dockerfile-alpine(line 11):Same change — remove
ENV ROOT_PASSWORD="password"and replace with the same comment.3.
opendj-packages/opendj-docker/run.sh(around lines 31-32):Update the password resolution logic to support Docker secrets and provide the default fallback. Replace:
With:
Note: The
HEALTHCHECKcommands in both Dockerfiles reference$ROOT_PASSWORD— this is fine because the variable will be available at container runtime when passed viadocker run -eor set inrun.sh. No changes needed to the HEALTHCHECK lines.Backward Compatibility
password) will still get it via the fallback inrun.sh.-e ROOT_PASSWORD=xxxatdocker runtime will continue to work./run/secrets/root_password) is added as a best practice.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: предложи решение Sensitive data should not be used in the ARG or ENV commands: opendj-packages/opendj-docker/Dockerfile#L11
SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "ROOT_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
Sensitive data should not be used in the ARG or ENV commands: opendj-packages/opendj-docker/Dockerfile-alpine#L11
SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "ROOT_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
Assistant: Let me also check how
ROOT_PASSWORDis used in the entrypoint and bootstrap scripts.Assistant: Now I have a complete picture of the issue and the codebase. Let me provide a comprehensive solution.
Problem
Both
DockerfileandDockerfile-alpineuseENV ROOT_PASSWORD="password"(line 11), which triggers the Docker lint warning SecretsUsedInArgOrEnv. Sensitive data like passwords should never be baked into an image layer viaENVorARGbecause:docker inspectand image history.Proposed Solution
Replace the
ENV ROOT_PASSWORDwith a runtime-only mechanism. The password should be passed either as a Docker secret (preferred for Swarm/Compose), a mounted file, or a plain runtime environment variable (docker run -e). The key point is to remove it from the Dockerfile itself.Changes to both Dockerfiles
1. Remove
ENV ROOT_PASSWORDfrom both Dockerfiles:The same change applies to
Dockerfile-alpine(remove line 11).**2. Update
run.shto support both env v...This pull request was created from Copilot chat.