[Intro Music]
I have just explained to you what is
default bridge network. And you
will now understand that containers
may communicate between each other
using own IP addresses assigned
randomly by Docker host. And we have
verified that using two busybox
containers. Next important concept
is environment variable. Let me
explain first what is an
environment variable, and
afterwards I'll explain you how
you're able to set custom
environment variable for specific
container. Great. We are now still
running two busybox containers. Let me
clear terminal in one of them,
and here simply type command 'env'
like so, and you'll get a list
of let's say key-value pairs. Here
are keys or names of environment
variables - HOSTNAME, SHLVL, HOME,
TERM, PATH, and PWD. And that's our
default variables that are set out
of the box for every busybox
container. And again, set of
environment variables is different
for different containers. And we
could easily verify that. Let's in
another step launch another
container, for example, ubuntu
container. 'docker run -it
ubuntu', and let's type 'env' here,
and you'll see a bunch of different
environment variables that were set
for this specific container. For
example, you see here a variable
called LS_COLORS, or
you see another HOSTNAME variable,
it is actually the same variable as
was set for those containers, but
HOSTNAME here is different, of
course, from this HOSTNAME. Also,
you may see that such variables
as PWD, HOME, are the same for
this container and this container.
But again, those variables are set
for each specific container
individually. Also, you are able to
verify environment variables
without logging into 'sh' or 'bash'
shell by doing following. Let me
go out from this container, clear
terminal, let's list the containers
that are currently running. There
are two busybox containers. And you
are able to use 'exec' command in
order to execute 'env' command inside
of the container. Let's do so.
'docker exec', and here will be ID of
the container, for example, this
one, 'a5', and next type 'env',
again here is command that will
override default command, and we
will actually create additional
process that will be executed
inside of specific container with
specific ID. Let's press Enter, and
you'll also see environment
variables. But notice that with
this command, you'll see less
environment variables than in this
case, because in this case, we are
looking at environment variables
inside of the 'sh' shell that
actually added some additional
environment variables when we have
logged into 'sh' shell. That's the
reason why here was set of
environment variables that is
larger than here. Wonderful. But
what is the essence actually of using
those environment variables? Very
often applications require some
initial setting parameters, like
password, the username or some
connection details or something
else. And you are able to set those
values before the start of the
application. For example, let's say
that your application needs to
connect to some external server and
for that it needs to use
credentials - username and password.
And it is not safe to store this
username and password inside of the
application files. It is not safe
at all, because anyone else may
easily read this username and
password and use for its own
purposes. That's why you are able
to initialize those parameters,
username and password when
application is started. And you are
able to use for that environment
variables. Also you are able to
override any default environment
variables if you want. Again, it's
a pretty common concept to use
environment variables in different
applications. And we will use those
variables multiple times throughout
this course. For now, that's all
for this lecture. And let's proceed
and next as promised, let's create
mysql container and see whether it
will be started or not by default
without any additional
environmental variables. I will see
you next. Bye-Bye.
[no audio]