container running on docker swarm not accessible from outside
Ran into this same issue and it turns out it was a clash between my local networks subnet and the subnet of the automatically created ingress
network. This can be verified using docker network inspect ingress
and checking if the IPAM.Config.Subnet
value overlaps with your local network.
To fix you can update the configuration of the ingress
network as specified in Customize the default ingress network; in summary:
- Remove services that publish ports
- Remove existing network:
docker network rm ingress
- Recreate using non-conflicting subnet:
docker network create \ --driver overlay \ --ingress \ --subnet 172.16.0.0/16 \ # Or whatever other subnet you want to use --gateway 172.16.0.1 \ ingress
- Restart services
You can avoid a clash to begin with by specifying the default subnet pool when initializing the swarm using the --default-addr-pool option.
docker service update your-service --publish-add 80:80
You can publish ports by updating the service.
Can you try this url instead of the ip adres? host.docker.internal
so something like http://host.docker.internal:80