docker-compose by default sets up a user-defined network for the services so they can talk to each other using the service name (so you don't need to find out their IP).
If you really wanted however you could setup multiple containers with the same network stack (breaking some of the isolation. With this setup other containers can access them via their ports through localhost but that also allows them to see all of their network traffic.
Example: https://pastebin.com/raw/U7CHqQFf
Have a look at https://docs.docker.com/compose/networking/ and https://docs.docker.com/compose/compose-file/#network_mode
Sort: Trending