Now you know what happens when you create new custom network and how to create new custom network.
And you know that in the custom network we are able to assign custom names to containers and they use
those names for communication and basically under the hood on our host.
There is DNS cetera that resolves those custom names to IP addresses of the containers and beauty of
this approach is that containers may have different dynamic IP addresses on different moments of time
but names will be still the same.
And Internal DNS cetera inside of the dock host will refresh those binding the hostname sorry name to
IP address and resolve them correctly.
And the week of verify that we were able to communicate between busy Books one and busy books to contain
those even after a start of correspondence for example busy books one container.
All right let's not proceed and no let's start over.
B should be my admin and my SPL containers.
But now in the cast on network recap that we have made a record of the commands that we have used for
start of the Maya scale etc. and BHP my admin but those comments where I used to in the first example
let me add here is description.
Example one where we have created those two containers in default breach network.
Let me add here to this creeps.
Example one default breach Network.
Great.
Let me know copied this entire section.
And in the same file commands the disks deep regret that this file is located in that Maya scale folder
here in our containers folder.
Let me copied this section and pasted here below like so and here will be an example too and we'll be
here.
Custom breach network and first of all of course we need to create a new custom network or we're able
to reuse the custom network that we have created before but for the sake of this example let's create
one more custom breach network and let's name it let's say my skill and he'll let me at this command
dock our network create and name will be Maya Skrill and that's it and his description of this command
create a custom breach network right.
And now we are able to use name of this custom network in those commands and we will run my Skrill and
BHP my admin containers in this custom Maya Skrill network and he let me add new line your step and
add additional option does dash network and here will be name of new network my scale.
And don't forget to add here backslash because we have split it the long command into multiple lines
and remaining part will be the same.
And basically let's also add the dash de option in order to start my s go container in by ground we
actually don't need to see logs and if you need to do so you are always able to use Docker locks command
with a D or name of corresponding container you want to read logs from great we have adjusted this throws
the command and let's also adjust to this second command that will run BHP my admin and here we'll be
communication over DNS name instead of address and actually DNS name will be name of the container.
Let me add this information here.
Name of the container.
Let me use option or I'll zip combination in order to make this long line visible here on the screen
and let me I just have this command dock Iran backslash and here we'll be on there's dish network my
scale again same network those two containers will be attached to the same network and also let me add
here that's the option and I'll run this container also in background all right we have placed those
two containers into the cost of network called Maya scale here and here.
But now most important part we need to adjust this set and we now want to communicate with my skill
container using its name actually DNS name and that's actually the reason why we have to create that
new custom network and we have adjusted this example number one.
All right.
Now we want to use hostname on name of the Maya scale container instead of this IP address let me removed
as they gathered from here and type my Eskil but now we need to set off a custom name for this Maya
circular container because we sites set up it will get randomly assigned name and that's not what we
want to help and remember that we'll be able to communicate with this container if it will go on in
with custom name it's not possible.
Okay.
Let's add one more option here and it will name look me it here there's this name and name will be my
Skrill.
And don't forget to add backslash like this and now we have actually created fully rocking configuration.
Here is the command for start of the Maya skill Sara.
And is command for a start of the BHP at my end container.
Wonderful.
Let's note does this set up and let's first create new custom network gold Maya scale.
Let me copy simply this comment.
Basically you are able to find this commands in GitHub repository for the scrolls but I recommend you
to grade those commands manually along with me in such a way you'll learn much much more and much much
better.
Great.
Let me a copy this comment gold two time and no A.L. let's create first Newcastle network Docker network
create my Eskil network was created and let's inspect it first Docker network inspect my scale and here
are the details about this custom network.
Notice that the here is new subnet that was assigned to this custom network it is maxed subnet off the
previous one that was used for cost of network we have created before them and here is new gateway that
was actually created at the docker host please note that if you are working on Mac or Windows this IP
address is created inside of the viewer doll machine that is running on macros or windows.
And if I'll have a look at the if config on my Mac now if convicted I You will not see such a bother
us here on the list.
I will still see only as a net zero interface and low back zero interface.
Sorry.
Here it is.
So here is a back and here is as I'm net zero with such IP address assigned to eat.
There are no addresses from those ranges eyes or this range that we see here or a nasal Ranger's assigned
to Oz or breach networks because those breach networks are created inside of the docker host.
Again it relates only to Mac OS and Windows.
If you are running the doc or direct on Linux you will see those new interfaces created directly on
your computer.
Great.
Let me proceed.
And now we are ready to create two new containers.
Let me go to our comments here.
Let me copy this comment that will create my skill container.
Let me copy it.
Go to terminal and paste here like so and press enter.
Notice that we will still use an environment variable that will set the Maya scale root password and
the two will be equal to my password.
Great.
Lets presenter and I see here a d of the container.
Let's verify a way as it does a running or not dogger appears.
And yes now it is up.
It's a good sign.
Let's not go back to visual studio gold and he'll just copy this comment book Iran and this comment
will create the additional container with BHP.
My admin image.
Let's copy it and then go by here.
Based anthro and I see a D of second container.
Let's now have a look at the docker the result and now I see two containers running here with BHP my
me image that was used for this container and here I see it.
Maya scale you mentioned it was used for this second image and noticed that.
Here you'll see custom name for this Maya scale image but there is still a random name assigned to this.
BHP my editing image and the reason for that is that we will not actually require communication from
Maya Skrill to BHP my Edmund.
That's why we haven't assigned custom name to this BHP my Edmond container but basically if you want
to keep it running and get back to it later on it's a good practice to assign custom name actually to
it as well.
All right let's now open up a web browser because we have created port mapping here what is and verify
whether we will be able to connect to BHP my admin and establish connection to my school container.
Let's try it.
Let's go to Google Chrome and actually I see this page still opened here.
Let's remove this part and let us enter a refresh page.
Welcome to BHP my admin.
Again this container is a brand new container.
It differs from the container it was running before.
All right here will be a user name for my high school database.
And here will be a password recap the password is a here.
Let me scroll up here was my password that we have set in this environment variable.
Let's go back to Google Chrome and here type my password click go and I am in and that means that communication
between BHP be my Edmond container and my Skrill was established successfully.
And that is the most important outcome from the previous and this lecture.
It was a long story and I explained you how to create custom bridge networks.
What is an environment variable.
How are you able to communicate in customer network using customer names.
And finally we can gather all those pieces together and we have launched those two containers.
BHP my admin and my school container now it's a good time to proceed and the next the let's lounge.
One more container in this network in this my Skrill costal network and basically you are ready to get
the challenge and you will need to create this custom container.
It will be at what press container yourself.
Challenge task comes next.
It will be pretty simple and I am sure you will be able to complete yourself without any additional
help.
All right see you next.
Bye bye.