41

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.

5 Answers 5

73

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

docker login

or more specifically:

docker login registry-1.docker.io
5
  • 2
    docker.io is the same than hub.docker.com ?
    – Bob5421
    Jul 19, 2019 at 8:35
  • 2
    The same. By the way, can update the question by output of docker info command? Jul 19, 2019 at 8:42
  • denied: requested access to the resource is denied docker hub just hates me. 3 hours of googling and stackoverflowing and trying and trying: access denied. - After all, I would not need but private repo for testing. Will try that next.
    – catch22
    Mar 9, 2022 at 19:22
  • as simple as : you need to be sudo. - so it was not docker hub not liking me ;)
    – catch22
    Mar 9, 2022 at 19:38
  • @ArgusDuong comment deserves to be part of the answer. Because the command "docker info" reveals the exact URL of where your docker registry is hosted. Namely 3 pieces of info that would be useful for the "docker login" , "docker pull" & "docker push" HTTP Proxy: ***** HTTPS Proxy: **** Registry: index.docke***** Apr 8, 2022 at 0:02
8

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>
2
  • 1
    much easier method Aug 15, 2022 at 7:15
  • In my case (WSL ubuntu) could not login with login /password. But when created a token and use it as password, logged in.
    – Dmytrq
    May 26 at 22:10
2

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

docker login registry-1.docker.io/v1
1

In my case docker daemon is not running, so I just restarted it and re-executed same command. It worked!!

-3

While login you may encountered with permission denied issues, in that case first give bellow command:

sudo chmod 666 /var/run/docker.sock

then use:

docker login

1
  • 3
    Do not change the ownership of that socket, it belongs to the docker group for better security. Instead of the first command, add your user to the docker group with usermod -aG docker $USER, log out and log in again. Dec 22, 2021 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.