We have just agreed that different containers using Mongo image and instead of the one of the containers
we have created the additional database and we have inserted the sum array growth inside of the new
collection called animals and we can verified that in another container.
We don't have access to the same database with same records and that was a good time to explain you
how you able to make let's say persistent database on your local computer and use it from different
Mongo containers.
Same relates actually to either databases like my scribble radius or something else.
Great.
Let me go out from this Mongo shell exit and let me actually stop a bullet actually doors to contain
there was that we have created Docker yes Dash 8.
And let me remove this one and this one I'll use docker container broom command and remove all containers
type.
Yes.
And if I'll have a look at containers now.
Yes there was still one container running.
Let me stop it first.
Darkness stop.
57 and let me actually.
Before deleting it let me launch it over again and the show you weekly where our database is actually
located inside of the container.
Sorry for that let me start it over Docker start.
57 Scalia terminal.
Now it is around here it is.
And no let's open shell brought us and there I'll demonstrate your way our database is located Docker
exec desk.
Item five seven and here type best.
Well let's open up.
Best process and here inside the let's.
The following let's list files and you'll see here folder called data.
Let's list contents of this folder less data and you'll see two sub folders config Debbie and Debbie.
Let's list contents of the Debbie sub folder.
Else data.
Debbie.
And you'll see a bunch of files that are actually related to database.
All those files including the common good dialog a storage B on collection of files while Tiger files
are actually Pirates of Mongo database.
And now every new container that you run using Mongo image creates actually new database inside of this
folder.
Data D.B..
There was also additional folder called config to be but we are interested at the moment only in this
folder.
Deep inside of data folder.
Now let me demonstrate you how we're able to create the database on our local computer and use it inside
of that one container.
And you may guess that for that we will use volume maybe.
And you're right.
Let's clear a terminal here.
Let's actually exit from best shell.
And now let me delete the simply this container the discount Iran and let me stop it darkroom stop.
5 7 and let's remove it Docker are m 5 7 container was removed and there are no containers at the moment
either in history or running great.
Now we are ready to create the volume open and create a database on our local computer.
In my case the smack in the same way you are able to create a volume weapon for Windows or any Unix
like system that the also rans Docker.
Great.
Let me open up our folder here.
Inside of a containers folder and here.
Let's create the new folder near doors folder that we have used in previous lectures and let's create
new folder called Mongo like so and here inside of this folder.
Let's create simply new folder called D.B. like so debut and let's leave this folder empty at the moment.
Now let's go to our timing now and let's see these two Mongo folder in the containers folder in my case
it is located on the desktop.
Let's go to desktop.
Let's go to containers and here let's go to Montego.
And if I'll list files here I I'll see a single folder.
Debbie let's list the contents of this folder at the moment.
Unless Debbie and now this folder is empty.
No let's create new Mongol container using Mongo image.
But now let's create additional volume mapping and endless map this Debbie folder to day ducks less.
Debbie folder inside of the container.
No worries that we have used the same approach before.
So this process is already familiar to you.
Let me actually close this step.
I don't need it anymore.
Let's work Justin this step.
Great Docker run and let's no use this D option in order to lounge Mongo deep waters in background.
Remember we have talked about this option before next.
Let's use.
There should be option volume mapping.
And here I'll use variable B A W dim.
But remember that we want to map Debbie sub folder in the Mongo folder to date that to be folder in
the container.
And for that I could combine variable with relative path and here simply at slash and type DB.
Because we want to map D.B. some folder in the Mongo folder.
Next comes column and afterwards lets bits if I path inside of the container it is data like salt.
Next let's add name of the image Mongo and that's actually all what we need to do in order to start
the new Mongo container using volume mapping.
And again this container will be started in the ground.
When I started we see shock of the newly created container.
And if I'll have a look at contain those now I should see that container is not currently Iran and here
was its idea.
Wonderful.
Let's now open up Mongo shell and let's try to create new database the inside of this container.
But before doing that let's no list files and folders inside of the DB folder in Mongo folder here.
Unless Debian.
And now I see that there are a bunch of new files that were created by who by Mongo container.
That is know Iranian before start of this container.
This Debbie folder was empty and now it is full of new files.
That is a great sign.
Great.
Let's now open up a mongo shell and let's create additional database and let's add one or two records
inside of the new collection.
Same as we did before.
Let me clear a terminal and here.
Let's use darkroom exec.
This idea.
Sorry I have forgotten to list the containers and get ideas to 6.
OK.
Docker.
Exactly.
This idea.
2 6 and here will be at Mongo.
Basically you are able to open up but bash shell and run Mongo down.
Let me actually try that approach.
Let's open up.
Best show and here type Monaco and the result is actually the same way I connect it from mongo shell
to mongo cetera.
Lets know your skill command showed these.
There are three abuse admin contact local let's create new TB use.
Let's say my debut switched to to be my debut.
And here instead of this my debut let's create new collection Gold.
Let's say I don't know.
Let's great post collection.
Debbie posts insert and here let's insert your record into this collection and here will be a post column.
Hey there.
Let's insert one more record.
How are you one more post
doing.
Well like so let's have a look at the contents of the posts collection.
Debbie posts.
Find there are three records.
Same as in previous case with animals collection rate.
But no those three records should be created on my local computer instead of the b folder.
Let's go out from this Mongo shall we call exit from mongo shell.
But we are now still located in the best shell inside of the container because we have started the best
shell using Docker exact command and the inside of it.
We have started Mongo shell.
Great.
Now let's go out from best shell type exit and notice that container will be still running because now
Dell was running process Mongo DB Docker.
P.S. I should see this container running and no less the following.
Let's first have a look at contents over the D.B. folder in Mongo folder on our computer.
Alas Debian and you'll still see some files here in this folder and you file.
Have a look at the doors files using options.
L.A. I will see that some of the files were changed just a few minutes ago for example this file collection
eight or this file index that's nine basically firm up of those files is white tiger and we are not
able to read the contents of those files directly.
Basically we're able to trade that let's use scout command cut the beast less and less so read the index
dash nine file for example index this 9 step and you'll see almost unreadable file but we are actually
able to extract some words from it.
Basically let me have a look also at the file for example.
This one collection Dash 8.
Let me use again.
Cut.
Command cut.
Debbie slash collection.
This aid like soul breath.
Step and in this output.
Yet in this output it seems that I see some text that was inserted into post collection.
How are you or doing well.
And so on.
It means that those records were created in the database located on my computer and that is a really
good sign.
No list right to the following.
Let's try to remove contain the longer container that discount uranium and create new container using
the same command using persistent volume weapon grade with the clear terminal here.
Let's stop running container.
DOCTOR Yes.
Doctor stop.
2 6 Doctor our m 2 6.
I'll remove it as well and don't drop in all containers and let's no use same command in order to start
over new Mongo container.
Well it's clear.
Terminal end.
Let me go through history and find this command somewhere here.
Yeah here it is Doc around there's D.
Well you might be in this V and the here.
Let's map same TB folder today that TB inside of the new Mongo container.
Again it will be brand new container without any relation to previous container left breast cancer.
Here was a D of New container.
Dr. Pierce.
Let's open up a best shell to this new container Docker.
Exactly.
This a team C D and the here will be on mongo.
Let's start directly Mongo process and here as before.
Let's list the abuse show debuts and I'll see my DB here on the list.
Let's switch to my BBM.
Use my debut and let's find some records in the post collection.
D.B. not both find like so and I'll see those three poles that were created before the game.
Now we were able to connect to the same database that was used in the previous container and by previous
container.
We can edit the records to that database and that is a really really important conclusion.
We are able to use same database by different containers and the such approach is used very often either
in development or in production.
Different containers connect to the same database.
Wonderful.
That's all for this lecture and let me actually go out from this Mongo shell and destroy current Iranian
container.
I don't need it anymore Docker is Docker.
Stop Cydia and docker r m Cydia and we are all set.
At the moment we know how to create a system database for example using Mongo image you are able to
use any other databases with the same approach and that's all for this lotion and nice list proceed
and the next list.
Try for example WordPress image and lounge WordPress container.
I'll see you next.
Bye bye.