How to connect springboot docker container replica via docker swarm cluster which need to connected to mongo replicas which is mentioned in etc/hosts

I have configured 3 mongo DB replica in 3 VM and added mongo DB instances name in etc/hosts of each VM. Now i need to connect my spring boot docker container via docker swarm cluster since its needed to read etc/hosts of each VM how would i mention its in docker since I am new to docker .All docker replica and mongo DB replica runs in same network please advice

etc/hosts file

#

10.10.1.2 mongo-1a
10.10.1.3 mongo-1b
10.10.1.4 mongo-1c

another ip for docker swarm manger node

10.10.1.5 manager node

#

all this ip is mentioned in each of the servers

i have tried to add –host host:ip in docker create service but it fialed

Source: StackOverflow