Search code examples
windowsdockerdocker-registry

Docker Registry does not have a custom hostname


I'm trying to configure a local container registry for development purposes, but by specifying the --hostname I can't reach the container.

docker run -d -p 5000:5000 `
--hostname docker-container-registry.local `
--restart=always `
--name registry `
-v C:\Programs\tools\docker\ContainerRegistry\auth:/auth `
-v C:\Programs\tools\docker\ContainerRegistry\certs:/certs `
-e "REGISTRY_AUTH=htpasswd" `
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" `
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd `
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt `
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key `
registry:2

in C:\Windows\System32\drivers\etc

# Added by Docker Desktop
192.168.1.2 host.docker.internal
192.168.1.2 gateway.docker.internal


192.168.1.2 docker-container-registry.local

What am I doing wrong?


Solution

  • I needed to change the Http ports!

    docker run -d `
    -p 443:443 `
    --hostname docker-container-registry.local `
    --restart=always `
    --name registry `
    -v C:\Programs\tools\docker\ContainerRegistry\auth:/auth `
    -v C:\Programs\tools\docker\ContainerRegistry\certs:/certs `
    -e REGISTRY_HTTP_ADDR=0.0.0.0:443 `
    -e "REGISTRY_AUTH=htpasswd" `
    -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" `
    -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd `
    -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt `
    -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key `
    registry:2