Open
Description
Description
Add support for providing registry passwords via environment variables, which is particularly useful in CI pipelines. For example, GitLab stores registry passwords in the CI_REGISTRY_PASSWORD
environment variable.
With the --password-env
flag, authenticating to a registry is as simple as:
docker login --username "${CI_REGISTRY_USER}" --password-env "CI_REGISTRY_PASSWORD" "${CI_REGISTRY}"
Alternatives Considered
-
Using
docker login -p "${VAR}"
with warning suppression- Shell history concerns don't apply with variable substitution
- Tokens are often short-lived, reducing security concerns
- Could introduce a way to suppress warnings via environment variables
-
Passing passwords via STDIN (current recommended method):
echo "${CI_REGISTRY_PASSWORD}" | docker login --username "${CI_REGISTRY_USER}" --password-stdin "${CI_REGISTRY}"
Avoids warnings but adds complexity to command chains
Activity
--password-env
flag #5972