Search code examples
ajaxdockercorsdocker-registry

Docker Registry 2.0 enable CORS


for a project i need to communicate with a privat Docker Registry via AJAX Requests, but I get an error because of the "Same Origin Rule" and I should enable CORS. I managed to start the Docker Remote API with CORS enabled (flag: --api-enable-cors) is there any equivalent way to do this with a private Registry? Or is there another way to enable CORS when starting a private Registry? [EDIT: FYI - Registry and the mentioned Remote API are on different Machines]

To set up de private Registry I followed the steps of the official Documentation: https://docs.docker.com/registry/deploying/ and I am using the Compose Version, to switch between Registry Version 1.0 and 2.0...

I'm quite a noob in Web implementation, but it is necessary for my project. Thanks in advance for help & sry for the bad english :)


Solution

  • No, unfortunately, the v2 registry does not support any CORS options as of this question and answer. The v2 registry is a brand new project written in a completely different language (Go versus v1's Python), and so many of the features available for v1 have not yet been implemented for v2. Actually the flag you used (--api-enable-cors) is a feature currently only available in the docker remote API, and not in the v2 registry.

    The way I get around v2's (currently) limited registry API is to use Jason Wilder's Nginx reverse proxy for docker, which uses his homegrown docker-gen utility to proxy for docker containers. Doing this opens up a bunch of "standard" features like authentication, CORS, SSL, etc. Even though right now this feature isn't implemented in the v2 registry, keep in mind that development is moving very quickly. Good luck!