pulling a private image
To pull a private image, you must first run docker login
to tell docker that you are authorised to pull the image. Afterward just run the normal docker pull <image name>
command.
Note: Docker stores your credentials in the ~/.docker/config.json
file.
Dockhub isn't the only place you can store your images, there is ECR (elastic container registry) from amazon, GCR (google container registry) from google and more. When you want to pull private images, you must also login to them too. the config.json
file has all the credentials for all the registries.
The file looks something like this:
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "c3R...zE2"
}
}
}
https://index.docker.io/v1/ is the default registry for dockerhub.
when you use Kubernetes (explained in further reading), other registries will be added to the config and they'll appear like so
{
"auths": {
"auth.docker.io": {
"auth": "TOKEN==",
"email": "EMAIL"
},
"docker.io": {
"auth": "TOKEN==",
"email": "EMAIL"
},
"https://index.docker.io/v1/": {
"auth": "TOKEN==",
"email": "EMAIL"
},
"https://registry-1.docker.io": {
"auth": "TOKEN==",
"email": "EMAIL"
},
"https://registry-1.docker.io/v2/": {
"auth": "TOKEN==",
"email": "EMAIL"
},
"registry-1.docker.io": {
"auth": "TOKEN==",
"email": "EMAIL"
},
"registry-1.docker.io/v2/": {
"auth": "TOKEN==",
"email": "EMAIL"
},
"registry.docker.io": {
"auth": "TOKEN==",
"email": "EMAIL"
}
},
"credsStore": "desktop"
}
As you can see there are many registries, technically the are all to dockerhub but this shows how many can be added.
Common docker registries:
-
auth.docker.io
-
docker.io
-
registry-1.docker.io
-
registry-1.docker.io/v2/
-
registry.docker.io