Linking in docker is complicated and difficult. There is another way to go about this, try it
Just create an overlay network for swarm mode.
docker network create -d overlay mynetwork
In swarm mode, just add every service who should communicate with another service to the same network.
docker service create --network mynetwork --name mymongodb ...
Other services in the same network can reach your mongodb service just over the hostname mymongodb.