37

I have several images in Docker Hub private repositories, and I need to pull these on remote machines using the Docker remote Rest API. Is there a way of authenticating remotely?

These are the calls I'd like to make remotely:

docker login
docker pull myrepo/myimage
Dan O'Leary
  • 2,660
  • 6
  • 24
  • 50

3 Answers3

68

Yes there is a way, you only need to specify the remote host

docker login myrepo.com

Then you can access to your images

docker pull myrepo.com/myimage

and you can specify a tag as well

docker pull myrepo.com/myimage:mytag

Hope this works for you.

Carlos Villalba
  • 799
  • 5
  • 7
  • I'd like to be able to do this using the remote api, which I don't think is possible – Dan O'Leary Sep 19 '16 at 09:28
  • Then you can do something like [this](http://stackoverflow.com/questions/24814714/docker-remote-api-pull-from-docker-hub-private-registry) – Carlos Villalba Sep 20 '16 at 18:38
  • If you want you can login with password typing: docker login --username --password – Jose1755 Jun 12 '18 at 14:58
  • FYI, `docker login` will write your username/password in base64 plaintext to `~/.docker/config.json`. So you may want to do `docker logout` afterwards to clear it. – wisbucky Jun 05 '19 at 23:49
  • @wisbucky Not true (checked in OSX) ```cat ~/.docker/config.json { "auths": { "https://index.docker.io/v1/": {} }, "HttpHeaders": { "User-Agent": "Docker-Client/18.09.2 (darwin)" }, "credsStore": "osxkeychain", "stackOrchestrator": "swarm" ``` – HereHere Jul 08 '19 at 10:46
  • 1
    @HereHere Looks like `Docker for Mac` automatically sets up the docker credential helper. But [by default (e.g. Linux), docker will write the credentials in base64 plaintext](https://docs.docker.com/engine/reference/commandline/login) to `~/.docker/config.json` unless you configure a credential helper. So you should not assume until you verify for your machine. – wisbucky Jul 08 '19 at 18:20
  • `sudo docker pull PRIVATE_REPO_NAME/DOCKER_IMAGE_NAME:TAG` worked for me – information_interchange Jul 07 '21 at 19:22
-1

I could fix the same issue only when I made the repo public. Make sure the repository is public then this is the set of instructions I followed in command line: Once logout from docker hub and login again.

1- docker logout

2- docker login --username=YOURUSERNAME Enter password when asked

3- docker pull "repositoryName"/"imageName"[:tag]

if "tag" is not included the default value will be "latest". Then check the images by docker images command to check if its been pulled.

Neela
  • 87
  • 6
-4

docker image pull 127.0.0.1:5000 /jenkins:latest

The above ip is your private machine's ip and 5000 is your mapping port /jenkins:latest is your image name which is present in your private registry, you can check it @ localhost:5000/v2/_catalog