Search code examples
javaspringrestdocker-registrydocker-java

Errors with notification endpoint for local docker registry


I have successfully deployed a local docker registry and implemented an listener endpoint to receive event notifications following the documentation for configuration using a sample insecure configuration file. Pushing, pulling and listing images work well. However, i still receive no event notification. The registry logs are throwing some errors i do not really understand:

level=error msg="retryingsink: error writing events: httpSink{http://localhost:5050/event}: error posting: Post http://localhost:5050/event: dial tcp 127.0.0.1:5050: getsockopt: connection refused, retrying"

I will appreciate any info.

The endpoint listener is implemented in java

@RequestMapping(value="/event",method = RequestMethod.POST,consumes = "application/json")
public void listener(@RequestBody Events event) {

Event[] e = event.getEvents();
Event ee = new Event();

for (int i = 0; i < e.length; i++) {
    System.out.println(e.length);
    System.out.println(e[i].toString());

}

Solution

  • So after several hours of research i.e. inspecting the private registry logs, i realized the media-type of the messages posted by registry listener to notification endpoints is either application/octet stream or application/vnd.docker.distribution.manifest.v2+json. Hence my solution was to permit all media types using the annotation consumes = "*/*" as specified in this Spring documentation i.e.

     @RequestMapping(value="/event",method = RequestMethod.POST,consumes =  "*/*")