Docker Registry local error: No such image: localhost:5000

Asked

Viewed 161 times

4

Good morning to all,

I’ve had a problem for two days that I haven’t been able to solve. I built an environment with 3 machines, with Docker swarm, one machine manager and two nodes.

The problem, when I start a service in the manager, I get the error: No such image: localhost:5000/integration-toa

I tried to create the local Registry on the machine manager in two ways:

1 - as a service

docker service create --name registry --publish published=5000,target=5000,mode=host registry:2

As a service, I can’t push the image:

[root@tslxdocker-hlg docker]# docker service create --name registry --publish published=5000,target=5000,mode=host registry:2
1z0a64ulmdvu6f2k08omgg3fj
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged
[root@tslxdocker-hlg docker]# docker push localhost:5000/integracao-toa
The push refers to repository [localhost:5000/integracao-toa]
Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: connect: connection refused

As a service, I have refused Connection error. However, on the two other host machines, I can connect to Registry:

curl localhost:5000/v2/_catalog
{"repositories":[]}

created the file /etc/Docker/daemon.json and restarted the Docker service

[root@tslxdocker-hlg docker]# cat /etc/docker/daemon.json
{
    "insecure-registries":[
        "localhost:5000",
        "127.0.0.1:5000"
    ]
}

I also tried to comment on the "localhost" line on /etc/hosts The error persists

2 - as a container

docker run -d -p 5000:5000 --restart=always --name registry registry:2

As a simple container, I can push the image in Registry, but the other nodes cannot connect to the registry:

push the image successfully:

[root@tslxdocker-hlg docker]# docker run -d -p 5000:5000 --restart=always --name registry registry:2
397f6fe083da78d5d0f08be3dfa336c01e328d8bbd46637dd52ac5b479a48c11
[root@tslxdocker-hlg docker]# docker push localhost:5000/integracao-toa
The push refers to repository [localhost:5000/integracao-toa]
82c687db4923: Pushed
fe849f218079: Pushed
bd029db62750: Pushed
03861ebeff3b: Pushed
286ab5bbe85e: Pushed
de2051a29c4c: Pushed
bac22f4e2b6a: Pushed
538ca12fd712: Pushed
f75e64f96dbc: Pushed
8f7ee6d76fd9: Pushed
c23711a84ad4: Pushed
90d1009ce6fe: Pushed
latest: digest: sha256:a6adadccfc2914d4a88f74cd8fba58105d223596e5b32ef7f71754056817e3f4 size: 2849

Failed to add service to swarm:

 docker service create --name integracao-toa --constraint node.labels.group==group01 --replicas 2 -p 3000:80 localhost:5000/integracao-toa
u1fwfqjs1vn1ml8665vbprzov
overall progress: 0 out of 2 tasks
1/2: No such image: localhost:5000/integracao-toa:latest@sha256:a6adadccfc2914d…
2/2: No such image: localhost:5000/integracao-toa:latest@sha256:a6adadccfc2914d…

interesting also that, as container, the nodes also fail to connect in the Registry:

curl localhost:5000/v2/_catalog
curl: (7) Failed connect to localhost:5000; Connection refused

So, I don’t know what else to do and I still have a question, what is the most correct way to run the local Registry? as a service or with Docker run?

Edit 1 In Docker info returns me the list of unsafe records (insecure-registries)

Insecure Registries:
 127.0.0.1:5000
 localhost:5000
 10.0.0.77:5000
 127.0.0.0/8

1 answer

0

I managed to solve.

Solution:

The daemon.json file should also be configured in the Workers and not only in the manager.

I also changed the name of the localhost image:5000 to 10.0.0.77:5000 (manager ip)

/etc/Docker/daemon.json

{
    "insecure-registries":[
        "10.0.0.77:5000"
    ]
}

In short

In Workers, I created the daemon.json file with insecure-registries and restarted Docker

In the manager, I ran Registry as a container.

docker run -d -p 5000:5000 registry:2

I created a new image tag (I didn’t use Atest because I want to know which version exactly is running, by Portainer) Docker tag integration-toa:14 10.0.0.77:5000/integration-toa:14

I pushed the image to the local Registry:

docker push 10.0.0.77:5000/integracao-toa:14

I ran the service of my application and used the "contraint" so that it was only published in the Workers (I added a label called group=group01 in the two Workers, so I can control by the manager on which machines my application will deploy)

docker service create --name integracao-toa --constraint node.labels.group==group01 --replicas 2 -p 3000:80 10.0.0.77:5000/integracao-toa:14

and again, I ran with the specific tag of version 14, instead of Latest, so I can more consistently visualize the version running on each node

nós executando, visualizando pelo Portainer

Browser other questions tagged

You are not signed in. Login or sign up in order to post.