fix: remove hardcoded OPENIDM_PASSWORD from ENV, use shell default in HEALTHCHECK#149
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Remove sensitive password from Dockerfile
fix: remove hardcoded OPENIDM_PASSWORD from ENV, use shell default in HEALTHCHECK
Apr 8, 2026
vharseko
approved these changes
Apr 8, 2026
maximthomas
approved these changes
Apr 8, 2026
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 OPENIDM_PASSWORD="openidm-admin"in both Dockerfiles bakes the password into every image layer, exposing it viadocker inspect/docker historyand triggering theSecretsUsedInArgOrEnvlint rule.Changes
Dockerfile/Dockerfile-alpine: RemoveENV OPENIDM_PASSWORD="openidm-admin"(line 7 in both files)HEALTHCHECK: Replace bare$OPENIDM_PASSWORDwith${OPENIDM_PASSWORD:-openidm-admin}— preserves the default while allowing runtime override via-e OPENIDM_PASSWORD=…Original prompt
Problem
Both
Dockerfile(line 7) andDockerfile-alpine(line 7) define a sensitive password viaENV:This violates Docker best practice rule SecretsUsedInArgOrEnv — sensitive data should not be baked into image layers via
ARGorENVinstructions, as it becomes visible throughdocker inspect/docker history.The
OPENIDM_PASSWORDvariable is only used in theHEALTHCHECKcommand in both files.Required Changes
1.
Dockerfile(line 7)Remove the line:
Update the
HEALTHCHECKcommand (line 32) to use a shell default value so it remains backward-compatible:Replace
$OPENIDM_PASSWORDwith${OPENIDM_PASSWORD:-openidm-admin}in the HEALTHCHECK curl command.The HEALTHCHECK line should look like:
2.
Dockerfile-alpine(line 7)Remove the line:
Update the
HEALTHCHECKcommand (line 33) identically — replace$OPENIDM_PASSWORDwith${OPENIDM_PASSWORD:-openidm-admin}in the HEALTHCHECK curl command.Why
${OPENIDM_PASSWORD:-openidm-admin}shell default.docker run -e OPENIDM_PASSWORD=...or Docker secrets.SecretsUsedInArgOrEnvwarning.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: Dockerfile#L7
SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "OPENIDM_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: Dockerfile-alpine#L7
SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "OPENIDM_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
Assistant:
Let me first examine the current Dockerfiles to understand how
OPENIDM_PASSWORDis being used.Assistant: Давайте разберём проблему и предложу решение.
Проблема
В обоих файлах (
DockerfileиDockerfile-alpine) на строке 7 парольOPENIDM_PASSWORDзадаётся черезENV, что:docker inspectилиdocker historyи увидеть пароль.OPENIDM_PASSWORDиспользуется в одном месте — вHEALTHCHECK(строка 32/33).Решение
Заменить
ENV OPENIDM_PASSWORDна передачу секрета в runtime через переменную окружения при запуске контейнера (docker run -e), а в HEALTHCHECK читать её из файла или из окружения процесса.Вариант 1 (рекомендуемый): Runtime-переменная + файл секрета
Убираем
ENV OPENIDM_PASSWORD=...и используем Docker-секреты или переменную окружения, передаваемую при запуске:Dockerfile:Dockerfile-alpine: