Received unexpected HTTP status: 502 Bad Gateway when performing the image pull from docker hub through the proxy.

Hello Team,

we are facing issue with the nexus docker proxy configuration, we are getting 502 bad gate way.

root@nexus-client-mechine:~# docker pull nexus.server.com:8083/library/nginx:latest
latest: Pulling from library/nginx
8a628cdd7ccc: Retrying in 1 second
75b642592991: Retrying in 1 second
553c8756fd66: Retrying in 1 second
10fe6d2248e3: Waiting
3b6e18ae4ce6: Waiting
3dce86e3b082: Waiting
e81a6b82cf64: Waiting
error pulling image configuration: download failed after attempts=6: received unexpected HTTP status: 502 Bad Gateway
root@nexus-client-mechine:~#

I was able to successfully pull the image directly from Docker Hub, retag it, and push it to our Docker-hosted repository in Nexus. Additionally, the image was successfully pulled from the repository on the client machine, confirming end-to-end functionality.

root@nexus-client-mechine:~# docker pull nginx:latest
latest: Pulling from library/nginx
8a628cdd7ccc: Pull complete
75b642592991: Pull complete
553c8756fd66: Pull complete
10fe6d2248e3: Pull complete
3b6e18ae4ce6: Pull complete
3dce86e3b082: Pull complete
e81a6b82cf64: Pull complete
Digest: sha256:09369da6b10306312cd908661320086bf87fbae1b6b0c49a1f50ba531fef2eab
Status: Downloaded newer image for nginx:latest

root@nexus-client-mechine:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nexus.server.com:8084/alpine latest aded1e1a5b37 8 weeks ago 7.83MB
nexus.server.com:8085/alpine latest aded1e1a5b37 8 weeks ago 7.83MB
nginx latest 4cad75abc83d 2 months ago 192MB
root@nexus-client-mechine:~#
root@nexus-client-mechine:~# docker pull nexus.server.com:8083/library/nginx:latest
latest: Pulling from library/nginx
Digest: sha256:09369da6b10306312cd908661320086bf87fbae1b6b0c49a1f50ba531fef2eab
Status: Downloaded newer image for nexus.server.com:8083/library/nginx:latest
nexus.server.com:8083/library/nginx:latest
root@nexus-client-mechine:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nexus.server.com:8084/alpine latest aded1e1a5b37 8 weeks ago 7.83MB
nexus.server.com:8085/alpine latest aded1e1a5b37 8 weeks ago 7.83MB
nginx latest 4cad75abc83d 2 months ago 192MB
root@nexus-client-mechine:~#

i am facing problem in the docker-proxy , below are the logs from client machine docker service

level=info msg=“Download failed, retrying (1/5): received unexpected HTTP status: 502 Bad Gateway”
level=error msg=“Not continuing with pull after error: error pulling image configuration: download failed after attempts=6: received unexpected HTTP status: 502 Bad Gateway”

Sona-type nexus logs says.

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target checking remote for update, proxy repo docker-proxy failed to fetch v2/library/nginx/blobs/sha256:e81a6b82cf648bedba69393d4a1c09839203d02587537c8c9a7703c01b37af49, content not in cache.

Regards,
Shijith

That suggests a certificate issue connecting to the remote

thanks for the replay,

we have downloaded the key file from the registry-1.docker.io:443 and added to java cacerts. but that didnt help

#keytool -printcert -rfc -sslserver registry-1.docker.io:443 > docker-registry.pem

Imported the certificate into the default Java truststore

#keytool -import -trustcacerts -alias dockerhub-cert -file /tmp/docker_hub.crt -keystore /usr/java/jre1.8.0_131/lib/security/cacerts -storepass changeit#systemctl

restart nexus

systemctl restart nexus.