Skip to content

Registry doesn't work with random host port binding #144

@britter

Description

@britter

For testing it's often desirable to start off a throwaway container and then create a port binding to a random host port. It looks however like the registry does not work if no explicit host port is passed to the run command:

$ docker run -d -p 5000 registry:2.8.1
068657e6b2f9ef4c3f7927b966bd4c0579aea6274832f34cfc6390bd901e8b76

$ docker ps
CONTAINER ID   IMAGE            COMMAND                  CREATED         STATUS         PORTS                     NAMES
068657e6b2f9   registry:2.8.1   "/entrypoint.sh /etc…"   3 seconds ago   Up 2 seconds   0.0.0.0:56997->5000/tcp   gallant_fermi

$ docker pull busybox:1.33.0
1.33.0: Pulling from library/busybox
Digest: sha256:315fd9e7f9056a6d76dfc2c63a5377c37aaa79faed354dce683147ed781adc77
Status: Image is up to date for busybox:1.33.0
docker.io/library/busybox:1.33.0

$ docker tag busybox:1.33.0 localhost:56997/busybox:1.33.0

$ docker push localhost:56997/busybox:1.33.0
The push refers to repository [localhost:56997/busybox]
Get "http://localhost:56997/v2/": dial tcp [::1]:56997: connect: connection refused

The same works if the port binding in the run command is set up using an explicit host port like -p 5000:5000.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions