How to describe context.xml linking tomcat and DB in docker-swarm

Hi , I’m studying docker-swarm
I have some questions.

How Can I connect tomcat and DB each other in docker-swarm?
I want to link tomcat that can scale out and DB
In tomcat , context.xml describes IP ,Port , some information about DB
but docker-swarm can’t use static IP
and when I restart services , DB’s IP is changed
is there a way to link tomcat and DB??
how Can I solve this problem??

I need your help!!