docker-registry-ui icon indicating copy to clipboard operation
docker-registry-ui copied to clipboard

CORS error on local setup despite setting Access-Control-Allow-Origin

Open ducin opened this issue 6 months ago • 3 comments

Hi, I use this docker registry UI and I have an issue...

Bug description

After opening registry UI (http://localhost:5002/) I get the following error popping up:

error occurred: Check your connection and your registry must have Access-Control-Allow-Origin header set to http://localhost:5002

Image

everything LOCALLY. I'm failing on the most basic local setup.

How to Reproduce

This is my entire docker-compose file:

services:
  registry-server:
    image: registry:2.8.2
    container_name: registry-server
    ports:
      - "5001:5000"
    volumes:
      - registry-data:/var/lib/registry
    environment:
      REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin: '[http://registry-ui:5002,http://localhost:5002]'
      REGISTRY_HTTP_HEADERS_Access-Control-Allow-Methods: '[HEAD,GET,OPTIONS]'
      REGISTRY_HTTP_HEADERS_Access-Control-Allow-Credentials: '[true]'
      REGISTRY_HTTP_HEADERS_Access-Control-Allow-Headers: '[Authorization,Accept,Cache-Control]'

  registry-ui:
    # docs: https://github.com/Joxit/docker-registry-ui/blob/main/README.md
    image: joxit/docker-registry-ui:latest
    container_name: registry-ui
    ports:
      - "5002:80"
    environment:
      - REGISTRY_TITLE=Deliveroo Registry
      - REGISTRY_URL=http://registry-server:5001
    depends_on:
      - registry-server

volumes:
  registry-data:

I've tried various combinations with this line:

  REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin: '[http://localhost:5002]'
  REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin: '["http://localhost:5002"]'
  REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin: '[http://registry-ui:5002,http://localhost:5002]'

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: Mac OS 15.4.1
  • Browser:
    • Name: Chrome v136
  • Docker registry UI:
    • Version: 2.8.2

ducin avatar Jun 03 '25 21:06 ducin

Hello there, thank you for using my project and submitting issues.

Have you read the documentation and specificaly all Available Options? Regarding your option

      - REGISTRY_URL=http://registry-server:5001

The documentation says

  • REGISTRY_URL: The default url of your docker registry. You may need CORS configuration on your registry. This is usually the domain name or IP of your registry reachable by your computer (e.g http://registry.example.com). (default: derived from the hostname of your UI).

I want to emphasize in the description "This is usually the domain name or IP of your registry reachable by your computer" => not the internal docker service name I suppose you can access to http://registry-server:5001 directly from your computer? Or it's a misconfiguration and the correct one should have been http://localhost:5001?

If this wasn't the issue I will need more information, like your browser console logs and browser networks

Joxit avatar Jun 05 '25 19:06 Joxit

Regarding the REGISTRY_URL assignment. I have a setup almost identical to what described in the docs as "Recommended Docker Registry Usage" right from the main page. The only difference is that port mapping for the UI is not 80:80 but 5080:80, with

REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin: '["*"]'

If I don't set REGISTRY_URL then everything works (but the pull commands all show incorrect :5080 port). But whatever I try to set REGISTRY_URL to (e.g. there is a resolvable local network DNS name https://docker.mydomain.com:5000 served via another nginx on the same bridge network) then it breaks and shows the same CORS error message regardless of any possible Allow-Origin I tried to set.

I don't understand the relationship between REGISTRY_URL and the CORS error, why it affects it and why it works without it.

It seems that the UI cares too much about REGISTRY_URL which supposed to be just an URL sent to users and resolvable in user networks, no matter what this name means for the UI container itself and its reachability from the UI.

dmitryzan avatar Aug 08 '25 04:08 dmitryzan

try to use image: registry:2.7, i met same problem when using image: registry:3.0.0

qisikai avatar Sep 09 '25 01:09 qisikai