Check docker connection for user and password

Viewed 310

we have some wizard with automation tool,

the wizard have 3 simple step

1 provide docker registry user

  1. provide registry password
  1. provide the domain to upload the image

it could be artifactory or dockerhub.

The problem is that sometimes user provide wrong credentials and the wizard says login success(using docker api's...), which is incorrect. as when the user push an image after he get an error un-autorized , my question is how should I handle it in the wizard ? maybe build the screatch image and push it to see if user provided the right credentials and authorized ?

my questions:

  1. is it possible to push an image without file, to provide the content via command? or to push some dummy image...
  2. is there other option to verify that the user successfully logged in? we dont get appropriate message when the user doenst provide the right credintials ...

UPDATE After checking it further it seems that we are not using docker we are using img and sometimes you can provide wrong password and you get the successful login info, is there a way to call to docker api/2 with the user server and password to see that user is successful login?

1 Answers

The most obvious solution would be calling

docker login -u username -p password server

(or any pendant from library if your wizard uses some sort of library like Docker.DotNet or similar) from your wizard and check the resultcode. If it's 0 the login is ok, otherwise it's not.

Related