All right, listen to examine on practice everything what we just discussed.
Let's go to the terminal here.
I already have four containers up and running.
And now let's find out which network was created for those containers by Docker compose for death.
Please type comment Docker Network LLC.
And here you'll find social network with such name images.
This gallery underscore default Dwyer is a bridge and heroes network ideal for this particular network.
Let's dive deeper and inspect this particular network, daughter network, inspect.
And next could be eyes or name of the network or network I.D..
Let's use name of the network was posted here.
And here are all the details about this particular network.
Let's go to the top, and here at the top, you should find such settings as subnet.
Here was subnet.
In my example, network prefix is 170 222 zero zero and that is 16.
Gateway is 170, 222 0.1.
And this IP address is internal inside of the Docker, and this gateway is set as default gateway for
all containers in this sub network.
Also, if you scroll a bit down, you'll find which containers are currently attached to this network.
And here you see first container with name image as Gallery Mongo Express one.
You'll see which IP address was assigned to this particular container.
There was also virtual address that was assigned of the container.
If you scroll down, you'll find information about all the containers, for example, front and container
and corresponding IP address of such container.
This IP address is different from this IP address.
Also, there was a Nas or Mac address that is different from this Mac address, and same information
could be found regarding all the containers Mongo container and API container.
All of them have a different IP addresses.
And if you want a good fuel output by this keyword, for instance, using Grab Command, Adhere Pipe
and at Grab and at such filter, and you'll find out that there are four different IP addresses assigned
to four different containers and they belong to the same network 170 222 zero zero Slezak 16.
Let's now look into one of the containers using Shell.
And for instance, let's open session to the Image Gallery API container and let's use container name
this one with me copied from here and enter Docker exec.
This idea here was container name.
And let's open up short shell.
No, I'm inside of the container, and let's enter your command host name like that.
Here I get host hostname that is actually based on container of Shahnaz for this particular API container.
In your case, hostname will be, of course, different.
And if I type host name this, I, I'll get actual IP address of this particular container.
It is 172, 22 0.3, in my example.
And now from this container, let's verify connectivity with all the containers in the same network
and with all the computers in the outside world.
And for that, we could utilize being a comment.
Let's first default gateway.
It's a US is 172, $22 0.1.
In your case, you could use same breath as you see here on this line and add one in the last octet
instead of three here, for instance.
So let's pin the full gateway and they get response number to verify connectivity with outside world.
And for example, let's be been the DNS server of Google.
Such IP address is public IP address, and it is located in the internet.
So let's pick it.
And I get response as well.
It means that internet is also reachable from the container.
No less connectivity with all the containers in the same Docker bridge network.
No, I'm inside of the API container.
And that's why list why to check on activity, for instance, with Mongo container.
And now let's say I don't buoy builders of the container.
And in such case, I could simply use name of the container and being it by name typing and add here
Mongo.
And they get the response from them on the container.
Notice how this name Mongo was resolved to IP address of the Mongo container, and it was done by internal
Docker DNS server.
And such mapping between this API address and this name was created there automatically after start
of all containers by Docker compose.
And this way, now I am able to communicate with AWS or container by its name.
Let's reach all the other containers.
For example, let's front end like that and they get response as well.
And IP address of the front and container is, of course, different from the API of the Mongo container
in the same way I could, which Mongo Express container like that, or containers are interconnected
with each other by Sosa's names and of course, by their IP addresses.
Also, if you want, you could reach containers by container names.
For example, here was container name from Express Container.
Let's try to use this name in the command and use container name.
And they also get a response from the container.
Simple, as did this name was also result doi PR of Mongo Express container.
It means that you could easily utilize service names that were defined in the Docker compose file,
for instance, Mongo or Mongo Express.
That's what we basically did on this line.
We set several name of the Mongo in one works plus configuration just the Mongo, because we know that
Mongo is name of Mongo service here, and this is why Mongo Express container is able to reach this
moniker container by its name.
That as a result, two IP addresses of actual container running Mongo image.
All right.
This whole container is communicate with each other internally, and the main outcome here is that you
could use IIS or services, names or container names in order to make connections between different
containers.
Built by Docker compose.
All right, let's exit from this soft shell.
And this actually it for network an overview for Docker compose.
I'll see you guys after the small break.