Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Docker registry v2 authentication failure #2008

Closed
theonlydoo opened this issue Jan 20, 2016 · 11 comments · Fixed by appc/docker2aci#120
Closed

Docker registry v2 authentication failure #2008

theonlydoo opened this issue Jan 20, 2016 · 11 comments · Fixed by appc/docker2aci#120

Comments

@theonlydoo
Copy link

Hi there,

I have a bit of a problem : I can't create a json to authenticate on a private docker registry, to pull images... I keep getting this error :
error converting docker image to ACI: unexpected http code: 401, URL:
Even using the config pattern described here. The json config files are present here :

/etc/rkt/auth.d/docker.json /usr/lib/rkt/auth.d/docker.json

Here is the format that I used :

{
    "rktKind": "dockerAuth",
    "rktVersion": "v1",
    "registries": ["r.mycompany.com", "reg.mycompany.com"],
    "credentials": {
        "user": "docker",
        "password": "REDACTED"
    }
}

Note : I tried with base64 encoded and decoded password.

@iaguis
Copy link
Member

iaguis commented Jan 22, 2016

docker2aci fix: appc/docker2aci#113

@theonlydoo
Copy link
Author

Thx!

@johnae
Copy link

johnae commented Feb 18, 2016

I'm running rkt 1.0.0 and I'm still having this exact problem.

@iaguis
Copy link
Member

iaguis commented Feb 19, 2016

I'm running rkt 1.0.0 and I'm still having this exact problem.

I just tested with a local docker registry and this file:

# /etc/rkt/auth.d/docker.json
{
    "rktKind": "dockerAuth",
    "rktVersion": "v1",
    "registries": ["localhost:5000"],
    "credentials": {
        "user": "iago",
        "password": "password"
    }
}

It seems to work for me:

$ rkt --insecure-options=image,http fetch docker://localhost:5000/busybox
image: remote fetching from URL "docker://localhost:5000/busybox"
Downloading sha256:eeee0535bf3: [==============================] 676 KB/676 KB 
Downloading sha256:a3ed95caeb0: [==============================] 32 B/32 B
sha512-2463c14e8f6f49cb03c3416d7bb15c48

Can you give more information about your scenario and paste your auth config? (with passwords redacted, of course :)).

@iaguis iaguis reopened this Feb 19, 2016
@iaguis iaguis modified the milestones: v1.1.0, v1.0.0 Feb 19, 2016
@johnae
Copy link

johnae commented Feb 19, 2016

@iaguis Sure. I guess I should have from the start. This is my auth config:

{
    "rktKind": "dockerAuth",
    "rktVersion": "v1",
    "registries": ["index.docker.io"],
    "credentials": {
        "user": "shortusername",
        "password": "password"
    }
}

The user is my short username on docker hub, the password is the password. Dockers own config likes it to be the email and base64 of "shortusername:password" in the auth field it seems. I've tried several combinations in the auth config but none of them seem to work. I get 401:s every time. It's a private repo on docker hub I'm trying to fetch.

@johnae
Copy link

johnae commented Feb 19, 2016

Also the error from rkt is this:

image: remote fetching from URL "docker://usernamehere/repohere"
fetch: unexpected http code: 401, URL: https://registry-1.docker.io/v2/usernamehere/repohere/manifests/latest

@iaguis
Copy link
Member

iaguis commented Feb 19, 2016

Can you try changing the registry url in the auth config to registry-1.docker.io?

@johnae
Copy link

johnae commented Feb 19, 2016

Yeah I tried that just now with the same result. Is this implemented in rkt:

https://docs.docker.com/registry/spec/auth/token/ - that seems to be what the v2 docker hub requires. To me it seems as if that 401 might be expected and the client should handle it by talking to the authentication service.

@iaguis
Copy link
Member

iaguis commented Feb 19, 2016

After a quick look, It seems it is implemented.

I could reproduce it with one of my private repos , I'll have a look.

@iaguis
Copy link
Member

iaguis commented Feb 19, 2016

The problem was that we weren't passing the username and password for the default docker registry.

When we implemented the v2 API in docker2aci, we modified the Docker URL parsing function to not infer the default registry URL because it could be index.docker.io (API v1) or registry-1.docker.io (API v2). The function was returning an empty registry, which means we weren't getting the password from the auth config file.

We can now infer the default registry URL because the API v1 is deprecated in the default registry. With that change, this issue is fixed.

Fix in docker2aci: appc/docker2aci#120

@iaguis
Copy link
Member

iaguis commented Feb 19, 2016

Not fixed yet, godep not updated.

@iaguis iaguis reopened this Feb 19, 2016
iaguis added a commit to kinvolk/rkt that referenced this issue Feb 19, 2016
iaguis added a commit to kinvolk/rkt that referenced this issue Feb 19, 2016
iaguis added a commit to kinvolk/rkt that referenced this issue Feb 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants