I have multiple services running each a mysql database.
I'm using docker-compose to deploy my apps in docker.
I need that all these services are in the same network.
I use different docker-compose file for each service.
My issue is: How can I prevent to container from being named the same (in docker dns) if they have the same name in different compose files.
Exemple:
service1.yml
version: '2'
services:
mysql:
image: "mysql"
network:
- anetwork
[...]
service2.yml
version: '2'
services:
mysql:
image: "mysql"
network:
- anetwork
[...]
This two files are in separate folders. After launching all docker-compose up. The containers appears with docker ps. On named service1_mysql_1 and the other service2_mysql_1.
But when I ping mysql dns name inside the network anetwork, both responds...
How should I fix this ? I am using bad practices ?
I have already tried: - Changing the name in each compose files