Docker Networking Beginner Question + Best Practices

Hello Guys, im fairly new to docker and i have a question.

I have ~4 Microservices, a Keycloak and a RabbitMQ Server i want to deploy via docker. Each Microservices has to be able to Speak to Keycloak and some need to speek to RabbitMQ.

To keep it clean i wanted to created a docker-compose file for keycloak one for rabbitmq and one per microservice. Is this the right way to do it? ( each Microservices has its own DB)

MS A, B, C, D need to be able to call Keycloak
MS C, D need to be able to talk to RabbitMQ

What is the best way to connect all the Microservices with the Keycloak / Rabbitmq Server(s)?
Some of the Microservices need to be able to talk to each others as well.

Ty in advanced

Attach the containers to a user-defined network and they can communicate with each other. This is probably the simplest way. I would use a single docker-compose for this, but it really depends on your use case, and how often you plan on bringing parts of the network down/up.

Here’s a guide on how to define custom networks in docker-compose.