Skip to content

cli/registry/login: Add the --password-env flag #5971

@octo

Description

@octo

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions