I'm trying to pull docker images from a private repository hosted in Docker hub https://registry.hub.docker.com/u/myname/myapp like this using the docker remote API. The doc is not clear as to how to specify the authentication credentials in a POST request like this
curl -XPOST -H "X-Registy-Auth: base64_encoded_authconfig_object" "http://localhost:4243/images/create?fromImage=myname/myapp"
This also does not elaborate on how exactly the authconfig is generated.
This talks about sending in a base 64 encoded json with a structure like this:
{
"index_url": {
"username": "string",
"password": "string",
"email": "string",
"serveraddress": "string"
}
}
But doesnt explain what is index_url and serveraddress. Are they
index_url = https://registry.hub.docker.com/u/myname/myapp
serveraddress = https://registry.hub.docker.com
The above configurations give me 404, probably the registry hub private repo is not being recognized.
I also tried base 64 encoding the contents of my ~/.dockercfg
{
"https://index.docker.io/v1/": {
"auth":"xxxxxxxxxxxxxxxxxxx==",
"email":"myname@myemail.com"
}
}
Could you tell me how to generate the base64 encoded authconfig object and get the above curl command working.
Thanks in advance
Docker version
Client version: 0.11.1
Client API version: 1.11
Go version (client): go1.2.1
Git commit (client): fb99f99
Server version: 0.11.1
Server API version: 1.11
Git commit (server): fb99f99
Go version (server): go1.2.1
I had the same issue.
Here's the "raw" AuthConfig object that you should use to pass the credentials:
You then have to "encode" it using Base64.
You didn't tell what language you're using, but if needed, this awesome site will let you encode your object in one click. Or, from a shell:
Then, just pass the encoded value to the header:
Here's a working example using
curl
andNote : I couldn't make it work (yet) by putting the remote registry endpoint/URL in the
serveraddress
field of the AuthConfig object. That's why I'm adding the registry host to thefromImage=
parameter.From this merged docker pull request, it seems that
X-Registry-Auth
header should be a base-64 encoded json string of the formanother reference link