dockerlabs icon indicating copy to clipboard operation
dockerlabs copied to clipboard

Building a Private Docker Registry Failing Due to Permissions Error and Requires `REGISTRY_HTTP_HOST` flag

Open GangGreenTemperTatum opened this issue 2 years ago • 1 comments

Local host registry permissions failing as per documentation instructions

To Reproduce Steps to reproduce the behavior:

  1. Start the container as per instructions
  2. Below error is produced when attempting to push to local registry and continuously loops until HTTP 500 server failure
$ docker run -d \
  -p 5000:5000 \
  --name registry \
  -v /registry/data:/var/lib/registry \
  --restart always \
  registry:2

$ docker push  localhost:5000/alpine:3.6
The push refers to repository [localhost:5000/alpine]
<CONTAINER-ID>: Retrying in 1 second **<---- Continuous loop**

Expected behavior Push of container to local repo should be successful first time

Screenshots NA. see code snippets

Desktop (please complete the following information):

  • MAC OS Ventura 13.1
  • Docker version 20.10.22, build 3a2c30b

Additional context Issue is resolved by adding REGISTRY_HTTP_HOST flag which sets correct working permissions and is successful

$ docker run -e REGISTRY_HTTP_HOST=localhost:50001 -d -p 5001:5000 --name registry registry:2

The push refers to repository [localhost:5001/alpine]
721384ec99e5: Pushed

GangGreenTemperTatum avatar Jan 30 '23 04:01 GangGreenTemperTatum

It seems like the issue you encountered was related to permissions on the local registry. The error message you received indicates that the Docker client was unable to push the container image to the local registry.

When you started the registry container using the command docker run -d -p 5000:5000 --name registry -v /registry/data:/var/lib/registry --restart always registry:2, you did not specify the REGISTRY_HTTP_HOST flag. This flag sets the hostname or IP address of the Docker registry server, which is necessary for the Docker client to authenticate and push the container image to the local registry.

Adding the REGISTRY_HTTP_HOST flag to the registry container with the command docker run -e REGISTRY_HTTP_HOST=localhost:50001 -d -p 5001:5000 --name registry registry:2 resolved the issue, as it correctly set the working permissions for the local registry.

collabnix avatar Mar 15 '23 17:03 collabnix