Thank you for the markup suggestions and corrections. I’ll have a look at the logs today. Where would I need to look to see the docker daemon log file(s)?
This is what my ~/.docker/config.json looks like:
{
"auths": {
"localhost:8082": {
"auth": "..."
}
},
"aliases": {
"builder": "buildx"
}
}
BTW, this was successful:
docker login http://localhost:8082 -u <username> -p <password>
But, unfortunately, the docker pull completely ignored it and failed to pull from Nexus 3’s Docker proxy and went directly to Dockerhub.
To view docker logs on my version of Ubuntu (see above): journalctl -fu docker.service
I now have a better idea of what’s going on. I’m writing some notes to help others that want to use an insecure (http) connection on their localhost for building docker containers (probably a common use case).
In my case, this my example problem:
- This forces docker to read the /etc/docker/daemon.json: sudo systemctl reload docker
- The journalctl -fu docker.service allow us to, in fact, see docker reading /etc/docker/daemon.json
- I grab the error’s url from this error:
dockerd[393960]: time="2024-05-16T21:04:22.885264587-05:00" level=info msg="Attempting next endpoint for pull after error: Head \"http://localhost:8082/v2/library/mysql/manifests/latest\": unauthorized: access to the requested resource is not authorized" spanID=ab8022fec9d8c4d6 traceID=d74b8485ca0441fbffe4e95619b1fd72
4. Now, know that the issue is an authorization problem, I did this:
curl 'http://<username>:<password>@localhost:8082/v2/library/mysql/manifests/latest'
5. It worked! And now, I get the following:
{"manifests":[{"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.digest":"sha256:c0de6b893513115fbaa4e643f8d2893630eb5362943c596717a7b6a78aef69ec","org.opencontainers.image.base.name":"oraclelinux:9-slim","org.opencontainers.image.created":"2024-05-09T23:51:50Z","org.opencontainers.image.revision":"a15b34a032f48089ee7b02d307d8f89a96b3bb76","org.opencontainers.image.source":"https:\/\/github.com\/docker-library\/mysql.git#a15b34a032f48089ee7b02d307d8f89a96b3bb76:8.4","org.opencontainers.image.url":"https:\/\/hub.docker.com\/_\/mysql","org.opencontainers.image.version":"8.4.0"},"digest":"sha256:e193c837211ee976fd9b638740a0264eff9b1d602d3affed7938ddbde7ff3035","mediaType":"application\/vnd.oci.image.manifest.v1+json","platform":{"architecture":"amd64","os":"linux"},"size":2855},{"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","vnd.docker.reference.digest":"sha256:e193c837211ee976fd9b638740a0264eff9b1d602d3affed7938ddbde7ff3035","vnd.docker.reference.type":"attestation-manifest"},"digest":"sha256:0e58aef73dd0a7b787428875aa2b64600c048aa5e55e8529b0bb716d4678ede9","mediaType":"application\/vnd.oci.image.manifest.v1+json","platform":{"architecture":"unknown","os":"unknown"},"size":842},{"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.digest":"sha256:5a8494823c700a8003ab2bb87220d0389362a33fd9086f20be1172925bca0825","org.opencontainers.image.base.name":"oraclelinux:9-slim","org.opencontainers.image.created":"2024-05-09T23:37:48Z","org.opencontainers.image.revision":"a15b34a032f48089ee7b02d307d8f89a96b3bb76","org.opencontainers.image.source":"https:\/\/github.com\/docker-library\/mysql.git#a15b34a032f48089ee7b02d307d8f89a96b3bb76:8.4","org.opencontainers.image.url":"https:\/\/hub.docker.com\/_\/mysql","org.opencontainers.image.version":"8.4.0"},"digest":"sha256:79bf3d05d420c85d21702dcde491ec36be535c79200cc83f1298dd838a6f1dad","mediaType":"application\/vnd.oci.image.manifest.v1+json","platform":{"architecture":"arm64","os":"linux","variant":"v8"},"size":2857},{"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","vnd.docker.reference.digest":"sha256:79bf3d05d420c85d21702dcde491ec36be535c79200cc83f1298dd838a6f1dad","vnd.docker.reference.type":"attestation-manifest"},"digest":"sha256:ad0644d4ea4c2291a9c3990d2e0373112058f7e7d8a3da4865c0c079b9c878cd","mediaType":"application\/vnd.oci.image.manifest.v1+json","platform":{"architecture":"unknown","os":"unknown"},"size":842}],"mediaType":"application\/vnd.oci.image.index.v1+json","schemaVersion":2}
- So, I get a good response from the curl. Now, I checked the proxy and it cached the image.
HOWEVER, the docker login acts strangely. I login to the localhost docker proxy with username and password supposedly successfully, then “docker logout” and it always says, “Removing login credentials for https://index.docker.io/v1/”. I was expecting it to say, " Removing login credentials for http://localhost:8082". This is very odd!
So, the docker pull still fails to cache image in Nexus 3 docker proxy.
[Update] I just found this issue: Docker is not passing auth informations when pulling from a mirror registry · Issue #30880 · moby/moby · GitHub. Sound like it’s a problem. What do you think?
BTW, this did not work for me as per issue …
Docker version 20.10.12
Nexus version 3.62.0-01
In settings repository enable Allow anonymous docker pull
Then need go to settings -> realms and enable Docker Bearer Token Realm. This help me with problem:
Error response from daemon: unauthorized: authentication required
I disabled the anonymous and I got this error in the log file:
dockerd[429543]: time="2024-05-16T22:30:11.871726625-05:00" level=info msg="Attempting next endpoint for pull after error: Head \"http://localhost:8082/v2/library/alpine/manifests/3.17\": no basic auth credentials"
So, if you have an ideas. Regards -Alan