[Intro Music]
So now you understand what is
environment variable, and also you
know how to verify which
environment variables are set in
specific container. Let's now exit
from all those containers and let
me basically actually stop them and
remove. Let me exit from busybox
here, and here. Let's list containers,
'docker ps'. There are no containers
running. 'docker ps -a', here are
stopped containers. And let's use
'docker container prune' in order to
remove all containers. Yes. Great.
Let's now proceed. And now let's
try to create mysql container, and
see whether it will be started or
not. Let's use 'docker run' command,
'docker run mysql', finding image
'mysql:latest', unable to find
locally. As usually pulling from
Docker Hub, extracting different
layers, and you see that one of the
layers already exists locally,
there is no need to pull it if it
already exists. Let's wait a bit.
All right image was downloaded. And
here you see attempt to start MySQL
server, Entrypoint script for
MySQL Server 8.0.19
started. And finally you'll see a
message, 'You need to specify one of
MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_
EMPTY_PASSWORD and MYSQL_RANDOM_
ROOT_PASSWORD'. And finally, this
application was terminated
actually, this container isn't running
anymore. 'docker ps', there are no
running containers. And that's what I
have told you before, you're not
able to start MySQL server out of
the box without initial at least
one environment variable. You need
to set up either MYSQL_ROOT_PASSWORD,
it's password for root user, or
you're able to use another
environment variable MYSQL_ALLOW_
EMPTY_PASSWORD, that will actually
allow login without password
for root user, that's not secure at
all, or you're able to use MYSQL_
RANDOM_ROOT_PASSWORD option that
will create a random password for
root user. And now it's a good time
to start MySQL using additional
environment variable. And you are
able to set environment variable
for a specific container using
additional options '-e'. Let's do
that. And let's set this option,
MYSQL_ROOT_PASSWORD. Let me copy
this environment variable name,
clear terminal, and again let's
use 'docker run' command, I'll create
a new container of course. And here
let's use the '-e' option.
Basically let me first use
'--help' here and show you this
option on the list. Let me scroll
up and it will be somewhere here.
Yes, '-e' or '--env list' : Set
environment variables. And you are
able to set multiple environment
variables by using '-e' option
multiple times. Great. Let's
proceed. 'docker run -e'.
Let's paste the copied
environment variable name, MYSQL_
ROOT_PASSWORD, and here will be
equal sign. And let's set it to
'my-password' like so. Again, it is a
password for root user. And
afterwards, we are able to specify
name of the image like so, 'mysql';
and let's now try to start this
container with set environment
variable MYSQL_ROOT_PASSWORD. And
now you see bunch of messages that
tell us that MySQL Server is
basically starting and now it is
actually running, and we are able
to verify that. Let's open up a new
tab and enter 'docker ps' here. And
yes, mysql container is now up,
here is CONTAINER ID, here is the
IMAGE that was used, here is
COMMAND that was executed, it's also
this image uses entrypoint instead
of cmd, 'docker-entry point.sh'. And
also you see that this container
listens at two ports 3306 and 33060,
this one. Great. This is how
we were able to start MySQL server.
But now let's try to connect to the
server. How we're able to do that?
We're able to do that in CLI
terminal, or we're able to use
graphical interface called phpMyAdmin,
and let me demonstrate you
how we are able to launch phpMyAdmin
and connect to this MySQL
server next. I will see you next. Bye-Bye.
[no audio]