In some scenarios, we might need to connect to an existing network from a docker container instead of create a new network. This would let us allow the resources in the existing network.
To join an existing network, you can define a network under each service and at the end of the docker compose file you can define the network to use the existing external network.
Syntax
services: service_name: image: image_name:latest restart: always networks: - existing-network networks: existing-network: external: true