I'm trying to work out how to properly use swarm mode in Docker. First I tried running containers on my 2 workers and manager machine without specifying a custom network (so I'm using the default ingress overlay network). However, If I use the ingress network, for some reason I cannot resolve tasks.myservice.
So I tried configuring a custom network like this:
docker network create -d overlay elasticnet
So now, when I bash into one of the containers, I can successfully resolve tasks.myservice but I can no longer access the port I've defined in my service creation under --publish externally (which I could when I used the ingress network).
Is there any way of either:
Use the ingress network and be able to resolve
tasks.myserviceor any other DNS record that will direct to all of my service containers?Or, use a custom network, but
--publishports correctly so I could access them externally?
EDIT
This is how I create my service,
Without a custom network:
docker service create --replicas 3 --label elasticsearch --endpoint-mode vip --name elastic -e ES_HOSTS="tasks.elastic" --publish 9200:9200 --mount type=bind,source=/tmp/es,destination=/usr/share/elasticsearch/config --update-delay 10s es:latest
With a custom network:
docker service create --replicas 3 --network elasticnet --label elasticsearch --endpoint-mode vip --name elastic -e ES_HOSTS="tasks.elastic" --publish 9200:9200 --mount type=bind,source=/tmp/es,destination=/usr/share/elasticsearch/config --update-delay 10s es:latest