first I have to create the network, I can either do it through setting the “driver” option as “bridge” in my docker-compose file
or by manually creating it outside of docker-compose using
docker network create -d bridge "werm.damn.selectiont.com"
Now in another docker-compose file, I want to access containers attached to that same network. to do so, under the “networks” option, put in the network but this time set “external” to true.
also under the networks prop within a containers props add this network
Great, but how about if we want to create this network dynamically using env vars, Below you can see me using a string. Let’s work in steps. As you can see, though I’ve labeled the network bam, I’ve given it a name property value of the last name is used. Though it is labeled “bam” its actually using the”werm.damn.selectiont.com”
then in your container options set “bam” as one of the networks
again, though I specify “bam”, the “werm.damn.selectiont.com” network is actually being referenced
here I am using env vars which in the end can equal any network you have running.