[Intro Music]
Alright guys, I have just explained
you how to use the '-t' option
along with container run command.
And now you know difference between
'-i', '-t' and '-it' options.
And we have actually tried the
different variants with 'docker run'
command. Now it's time to start the
creation of multiple containers
using the same image. And in this
lecture I'll create two
containers using ubuntu image, and
I'll demonstrate that those
containers are completely two
different containers, and they are
fully independent, except the fact
that they basically share resources
of Docker host, I mean the CPU
resources, RAM, and disk. Great.
Let's get our hands dirty, and
let's create first container based
on ubuntu image. 'docker run -it',
I used those two options here,
'ubuntu', because I want to log in
into that container, basically into
the default process called 'bash'. Let's
press Enter, and now I'm inside of
the container. That is the first
container that we have just
created. Let's for example, list
files here. And let's, for testing
purposes, create a new folder here
called 'test'; 'mkdir test'. Let's 'cd'
to this 'test' folder; and let's
create here file 'touch test.txt'.
And let's go back out of this
'test' folder. And if I list files
and folders here, you'll see this
'test' folder here on the list.
Wonderful. Let me now create one
more container based on the same
image, ubuntu. Let me open up a new
tab. Basically, let me drag this
tab here and put those two tabs
side by side, like so because I
want you to see differences between
those two containers. Okay, here is
the first container with ubuntu
image; and here in this container,
we have created a new folder called
'test'; and inside of that folder
there was file called 'test.txt';
and here in this window, let me
start one more container based on
the same image ubuntu. Same command,
'docker run -it ubuntu'.
Container was started. And notice
that there was difference in
container IDs. Here was actually ID
of this container; and it is
automatically taken as the host
name of this container, of this
computer actually; and here is
this ID that was used for this
container number one. Great. Let's
now list files and folders inside
of this container, 'ls'; and you'll
see same set of folders and files
that we have seen here in this
container before creation of the
'test' folder; and there was no 'test'
folder inside of this container.
This shows you that every container
has its own separated file system.
And file systems of different
containers don't overlap. They are
completely independent. But of
course, those file systems are
stored on the same Docker host. In
this case, Docker host is virtual
machine inside of which those
containers are run. And this virtual
machine is basically running on
this macOS computer, same picture
for Windows computer. Great. I
could also create the some files
and folders inside of this
container. And let me do that
quickly. For example, I could
create a folder called 'test2', 'cd'
to 'test2'; and here let's create
the file 'test2.txt'. Let's list
files here. You'll see 'test2.txt'
file inside of 'test2' folder,
and if I'll 'cd' out of this folder,
you'll see 'test2' folder here in
the root of this container. And
again, if I repeat the same command
here, in container number one, you
will see that there was still 'test'
folder and no 'test2' folder.
Great. That is the difference
between this container and this
container. And now you see that the
containers are fully independent
and they again only share CPU
resources of the Docker host and
RAM. It means that each of those
containers may take up to 100%
resources of the Docker host. And
of course there is possibility to
limit the maximum size of resources
that each container may utilize.
And we will get back to that later
on in this course. Also, you'll see
that those containers have
different host names. And actually
you could verify hostname by typing
the 'hostname' command like so, and
you'll see a hostname of this
container, and actually this host
name is shown here after login
into the container, and if you would
like to check hostname here on this
container you could use same
command 'hostname', and you'll see
hostname of this container. We
could also verify IP addresses of
every container, and for that you
could use command 'hostname -i',
and 'hostname -i' in this
container, and you'll see that those
containers have different IP
addresses. But they are basically
from the same network. And it is
default bridge network inside
of the Docker host. Great. That's
how those containers differ. And
the goal of this lecture was to
demonstrate to you that containers
are fully independent, and have
different file systems. Let's now
proceed and in the next lecture,
let's develop this topic, and let's
try to create two different nginx
servers that will host different
files from different folders. And
again, that will prove that you are
able to create multiple containers
based on the same image. And one
more thing here that I wanted to
tell you is that in this case, you
were not prompted to download any
new image, something else, image was
already in your local cache, and it
was simply reused for both
containers. That's why you have
created those containers pretty
fast, in a matter of seconds. And of
course, if I will create a new
container, ubuntu container now, it
will get the clean file system
without any 'test' or 'test2'
folders that we have created in
previous containers. Wonderful.
Let's now proceed and next let's
create the two nginx containers
with two different set of files.
See you next. Bye-Bye.
[no audio]