Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with the --username option in docker login when using --password-stdin #5792

Open
aminelch opened this issue Feb 3, 2025 · 1 comment

Comments

@aminelch
Copy link

aminelch commented Feb 3, 2025

Description

There seems to be an issue with the usage of docker login when providing the --username and --password-stdin options. The --username option is being ignored or misinterpreted when placed after --password-stdin. Based on the official documentation, it should work in this order, but it leads to an error message when executed in this sequence.

Reproduce

Use the following command to log in to a Docker registry:

$ echo "$TARGET_GITLAB_PAT" | docker login -u "$TARGET_GITLAB_USERNAME" --password-stdin registry.gitlab.com
Must provide --username with --password-stdin
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 1

Image

Expected behavior

Expected Behavior: The --username and --password-stdin options should work regardless of their order, as the documentation clearly specifies both options.

docker version

NA

docker info

NA

Additional Info

No response

@mohammedfuta2000
Copy link
Contributor

There's an issue with populating your variables. Try this:

Populate the variables:

export TARGET_GITLAB_USERNAME="username"
export TARGET_GITLAB_PAT="pat"

Confirm they're populated:

echo $TARGET_GITLAB_USERNAME     
echo $TARGET_GITLAB_PAT 

Authenticate with GitLab registry:

The following command will succeed regardless of the order of --username and --password-stdin options:

echo "$TARGET_GITLAB_PAT" | docker login registry.gitlab.com --password-stdin -u "$TARGET_GITLAB_USERNAME"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants