Local registry on swarm not accessible

Hello,

Expected behavior

I want to create and use a local registry on the swarm in order to deploy my service from It.

Actual behavior

I can’t push or pull any image to the local registry.

Additional Information

I suppose it is because I can’t access to localhost with the ssh connection on docker in docker for AWS.
The goal is to be able to scale and update a service on the swarm easily.

Steps to reproduce the behavior

~ $  docker service create --name registry -p 5000:5000 --reserve-memory 100m --mount "type=bind,source=$PWD,target=/var/lib/registry" registry:2.5.0
p4jojcbha53zb3nce7laolv1c
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged

~ $ docker tag alpine localhost:5000/alpine

~ $ docker push localhost:5000/alpine
The push refers to repository [localhost:5000/alpine]
Get http://localhost:5000/v2/: net/http: request canceled (Client.Timeout exceeded while awaiting headers)