MatUtter MatUtter - 1 year ago 136
Node.js Question

Cannot get a valid response from Docker Registry remote API

I'm using Nodejs & request to form my API calls, I can make API calls directly to a UnixSocket with it however it fails every attempt when requesting from the Docker registry container I have running, so I believe it's the fault of my registry configuration.

I've set it up out of the box just like the doc steps below.

docker run -d -p 5000:5000 --restart=always --name registry registry:2
docker pull alpine
docker tag alpine localhost:5000/alpine
docker push localhost:5000/alpine

The code I'm using to request is below, it receives a
404 not found

const request = require('request')
method: 'GET',
uri: 'http://localhost:5000/images/json', // status 404
// uri: 'http://unix:/var/run/docker.sock:/images/json', // this works
headers: { host : 'localhost' }
}, (e, res, body) => {
if(e) return console.error(e)
console.log(res.statusCode == 200 ? JSON.parse(body) : res.statusCode)

To be clear, this code is just to demonstrate that I'm making a GET request that should be well-formed.

What has to be done to allow a running registry container respond to the remote API?

Answer Source

Docker Registry doesn't have the /images/json API, and the Docker Registry's API does not compatible with docker engine API.

To get the image list of Docker Registry, please try GET /v2/_catalog. Full document can be found here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download