[Intro Music]
Our goal at the moment is to
establish communication between two
containers. And we will start
simple and I'll explain you how
you're able to ping one container
from another in default bridge
network. And for that, we will
create two busybox containers.
At the moment there was a 'wordpress'
container running and it is
completely safe to stop it and
remove at the moment. But no
worries, we will get back to
'wordpress' container a bit later.
All right, let me stop this
container 'docker stop 75',
[no audio]
and let's prune all stopped containers
'docker container prune'. Yes. And all
containers were removed. Wonderful.
Let's now create two busybox
containers. Here in this step will
be first one and in another tab we
will create second one. Great.
Let's use 'docker run' command. Recap
that 'busybox' image is already
in our local cache. 'docker run',
I'll use two options '-it'; and
here will be 'busybox', like so. And
in another tab let's also start
one more 'busybox' container 'docker
run -it busybox'. Great. We have
logged into 'sh' shell here in this
container, and in this container. And
now let's verify which IP addresses
were assigned to those containers.
For that you could use command
'hostname -i'; and here let's
enter this command as well,
'hostname -i', and you see that
the IP addresses that were assigned
to those containers are different.
Here you see that this address ends
with 2, and here this address
ends with 3. But you may notice
that those IP addresses are from
the same sub-network. It is
basically Private Sub-network
called 172.17.0.0 with subnet
mask 16. And those IP addresses
from this range are used for
assignment to containers by
default, it is actually default
network. And let's now verify
whether those containers are able
to communicate between each other
or not. And for that, we will
simply use ping utility that will
perform a connection test from one
IP address to another. And from
this 'busybox' container, we could ping
another IP address of another
container using ping utility. This
utility is available in 'busybox'
container out of the box. Let's use
it, 'ping 172.17.0.3', and you see
that we get response from another
container. And that means that
there is connection between two
containers and they are able to
communicate over any TCP or UDP
ports, because this ping utility
works on the third level of the OSI
model, and it means that all levels
up will work as well. No worries,
we'll get back to network concepts
a bit later in the course, and I'll
explain you all of that in details.
For now you need to understand that
those containers are able to
communicate over any TCP or UDP
ports. Wonderful. Also, you're able
to verify connection from this
container, and here you're able to
use the same command 'ping
172.17.0.2, and you of course will
get response from this 'busybox'
container. Great. That's how IP
addresses are assigned by default
containers and how you're able to
communicate between containers by
default in default bridge network.
Also you are able to verify which
IP address was assigned to specific
container by using the command
'docker inspect'.
Let me open up a new tab here, and
first let's enter 'docker ps', and
you'll see two containers running.
Here is the first ID and here is the second
ID. And now let's use 'docker inspect'
command, 'docker inspect', and pass
here ID of any of the containers.
Let's use this ID. Let me copy it,
paste here. And you'll see IP
address almost at the end of this
output. Here is the IP address
assigned to this 'busybox' container.
And if you'll verify the details
about another container, let me do
so, 'docker ps', 'docker inspect', and
let's use ID this one, copy it,
paste here, you'll see another IP
address assigned to this container.
You may also notice that there was
Gateway setting and it is equal for
both containers. It is actually
virtual IP address located at the
Docker Host, and it acts as a
default gateway for all containers
that are running in default bridge
network. Wonderful. These aer
fundamentals of IP networking, by
default in Docker. Again, here was
default network 172.17.0.0, and
subnet mask is 16. Here you see
'IPPrefixLen' as third line
here in this output. And that means
that you may see IP addresses like
172.17.5.6, or 100.7, or like in this
case 172.17.0.2, 5, 10, and so on. But
this part will be the same for all
IP addresses, it is prefix. All
right, that's the basics of IP
networking between containers that
are created in Docker by default.
Also let me demonstrate to you that you
are able to connect to any IP
address or hostname in internet
from container. And for that you
could use same command ping and for
example, type 'ping google.com', and
you'll get response from Google,
you will get response actually from
IP address of one of the Google's
servers. Great. That's all what I
wanted to show you here in this
lecture. And the most important
outcome is that containers by
default may communicate between
each other using IP addresses.
Wonderful. Let's now proceed and
next let's try to create mysql
container, and see whether we will
be able to start it without any
options or not. I'll see you next. Bye-Bye.
[no audio]