dockerdocker-composedocker-api

Docker push on local registry gets stuck


I'm trying to push an image to a local docker registry deployed with docker-compose the following way:

services:
  docker-registry:
    image: registry:2
    restart: unless-stopped
    environment:
      - REGISTRY_STORAGE_DELETE_ENABLED=true
    volumes:
      - registry-data:/var/lib/registry

Note: this is inside a Dev Container and registry port is forwarded directly from .devcontainer.json, but it is equivalent to forwarding 5000:5000 in docker-compose, I have no problem contacting the registry

Whenever I attempt to push an image on the registry, I have a layer getting stuck to 48.8MB (attempted a lot of times, recreating the service, deleting the volume, restarting everything)

 ~ docker push localhost:5000/some-image
Using default tag: latest
The push refers to repository [localhost:5000/some-image]
1562583dd903: Preparing 
1562583dd903: Pushing  227.3kB/19.88MB
1562583dd903: Pushing   6.14MB/19.88MB
1562583dd903: Pushing  9.122MB/19.88MB
1562583dd903: Pushing   18.3MB/19.88MB
1562583dd903: Pushing  19.98MB
86959104e6a0: Pushed 
86959104e6a0: Pushing  18.25MB/2.068GB
86959104e6a0: Pushing   22.7MB/2.068GB
86959104e6a0: Pushing  50.83MB/2.068GB
a3038b-3bfe-4903-951d-8d5529552f96 
c735c85250bd: Mounted from some-other-image
b0f6b3bc04d7: Mounted from some-other-image 
f31afd463445: Mounted from some-other-image 
a9099c3159f5: Pushing [===================>                               ]   48.8MB/124.1MB

The command is then stuck forever. I tried pushing from docker command on my host and also from docker API using Golang code, I have encountered the same exact behaviour.

Any idea on what is wrong here?


Solution

  • I found a solution to the problem (but not the reason), this seems related to Dev Containers.

    I ran the service this way in the docker-compose.yml run by devcontainer.json:

    services:
      docker-registry:
        image: registry:2
        restart: unless-stopped
        environment:
          - REGISTRY_STORAGE_DELETE_ENABLED=true
        volumes:
          - registry-data:/var/lib/registry
    

    In devcontainer.json, I forwarded the ports this way as I'm used to doing to have the ports listed in VS Code ports section:

    "forwardPorts": [
      "docker-registry:5000",
    ],
    "portsAttributes": {
      "docker-registry:5000": {
        "label": "Docker registry",
        "onAutoForward": "silent",
        "requireLocalPort": true
    }
    

    This resulted in correct forward of port 5000 of the container to port 5000 on the localhost.

    However, by removing these references from .devcontainer and forwarding ports directly from the docker-compose.yml, I no longer have the initial issue:

    services:
      docker-registry:
        image: registry:2
        restart: unless-stopped
        environment:
          - REGISTRY_STORAGE_DELETE_ENABLED=true
        volumes:
          - registry-data:/var/lib/registry
        ports:
          - 5000:5000