Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login to Docker Hub by command line

Tags:

docker

I have read some Docker tutorials and I see this command line:

docker login -u LOGIN -p PASSWORD

But the registry server URL is never set. How does the docker command know the registry URL? What is the URL for Docker Hub Registry? I have tried this:

docker login -u LOGIN -p PASSWORD cloud.docker.com

but it does not work.

like image 237
Bob5421 Avatar asked Jul 19 '19 07:07

Bob5421


People also ask

How do I log into my docker desktop?

Go to the Docker Desktop menu and then select Sign in / Create Docker ID. Enter your Docker ID and password and click Sign in. After you have successfully signed in, Docker Desktop prompts you to enter the authentication code. Enter the six-digit code from your phone and then click Verify.

How do I log in to Docker Hub?

Once you’ve successfully logged out, you can then log in with the command: Where USER is your Docker Hub username. You will then be prompted for your Docker Hub access token. Paste the token into the CLI prompt and you’ll be logged in to your Docker Hub account and should be able to pull down images at will.

Why can’t I logout of my Docker account?

Before you do this, you must issue the logout command in the Docker CLI. The reason for this is that Docker might have cached your previous login credentials and will fail to accept the new access token. This has tripped me up before and the only way around it is to first issue the command:

How to read a password from a file in Docker?

Alternatively you can read a password from a file, and pass it to the docker login command using STDIN (handy for automations): When you log in, the command stores base64 encoded username:password pair in $HOME/.docker/config.json on Linux or %USERPROFILE%/.docker/config.json on Windows:

How do I set up a private Docker registry?

To start using a private Docker Registry a user usually should run the docker login command and set a username and password that will be cached locally.


3 Answers

If you want to login to the default Docker Hub repository, simply use:

docker login

or more specifically:

docker login registry-1.docker.io
like image 172
Argus Duong Avatar answered Sep 20 '22 19:09

Argus Duong


You may need to use a specific registry version, for me this worked.

docker login registry-1.docker.io/v1
like image 32
lacostenycoder Avatar answered Sep 17 '22 19:09

lacostenycoder


You can also login using a Docker Hub Access Token: https://docs.docker.com/docker-hub/access-tokens.

To do that:

  1. Access your Docker Hub account.
  2. Click on your avatar (on the page top right side).
  3. Click on Account and Settings.
  4. Click on Security (on the page left side in the middle).
  5. And then click on New Access Token button.

enter image description here

  1. Give a token description, define the token permissions and click on Generate.
  2. Copy and save your token.

Then log in with your new token. Type docker login -u <your-username> on your terminal and paste your Access Token when requested by the password.

docker login -u <your-username>
like image 25
claudius Avatar answered Sep 17 '22 19:09

claudius