[Intro Music]
All right, I hope you were able to
complete this challenge. And now
let's do it together. And I'll first
prepare commands in VS Code
file. I have already created the
folder called 'elasticsearch'; and
here inside there is already a
file called 'elasticsearch-
commands.txt'; and you
are able to find this file
basically in GitHub repository, but
we will use it in the next lecture.
Now, I'll create a new file here in
this folder named 'commands.txt',
same as we did for wordpress and
mysql examples, 'commands.txt'.
And here first command will be
creation of the custom network,
CREATE NEW CUSTOM BRIDGE NETWORK.
And I'll use here command 'docker
network create', and name of this
custom network will be 'elastic
search', like this. Next, CREATE
ELASTICSEARCH CONTAINER, ELASTIC
SEARCH CONTAINER, like so. Here I'll
use 'docker run' command, I'll use
backslashes to separate different
sub-parts of the same command. And
next let me give name to this
container, '--name elasticsearch',
like so. Next, I have asked you
to create port mapping, here will be
'-p'; and external port will be
9200 same as internal port 9200.
I'll expose same port to outside.
Next, let's specify here name of
the image; and name will be
'elasticsearch', like so. And also let's run
this container in background. But
it is optional. You could run it in
foreground if you want. Also,
we need to specify here custom
network name, '--network',
and name will be 'elasticsearch'. It
is the name of this network we have
created here above. And it seems
that that's all what I asked you to
do. All right, next container will
be 'curl' container, CREATE CURL
CONTAINER. And here we will use
again, sorry, I have forgotten to
add here backslashes, like so,
backslash here, here and here. And
here, let's create 'curl'
container, 'docker run \',
network will be the same. Let me
copy this command from here, paste
like so. Next, let's give it also
name, '--name'; and name
will be let's say 'curl' simply;
and we will not expose any ports. And
here next will be name of
the image we want to use, and the
name of the image is, let me go
to history somewhere here, and let
me copy image name from here.
Okay, let me go back to VS Code,
and let me paste the image name
here, and I'll want to override
default 'curl' command that is hard
coded into this image, and I want
to override it with 'sh' command or
you're able to use 'bash' command as
well, but I'll use 'sh' here like so.
And it seems that that's all that we
want to do in order to run those
two containers. Let me quickly
check. network is 'elasticsearch', here,
here. And we create network here,
we expose port here, and also we
will be able to reach this
container by its name,
'elasticsearch'. That's actually the
purpose why I have asked you to
create separate custom network. All
right, let me first create
this custom network. Let me copy it
and go to terminal, create new
custom network, network was created,
let me know run 'elasticsearch'
container. At the moment I don't
have 'elasticsearch' image in local
cache, that's why first we need to
pull it. But basically with 'docker
run' command, we will first pull it,
and afterwards immediately create
container out of it. But actually
let me quickly check the name of
this image. Let me go to Docker Hub,
and check whether name is correct.
'elasticsearch' like so. And yes,
image is correct. There is
official Docker Image called
'elasticsearch'; and there are more
than 1 million downloads. Great.
Let me go back to this file, let me
copy this command, go to terminal,
and let me launch 'elasticsearch'
container here. Unable to find image
locally. And there is an error
'manifest for 'elasticsearch:latest
not found:', let me check probably
there is some error here. Let me go
into this container, let me copy
basically this command, and let me
try to pull it first,
'docker pull elasticsearch', and
name is exactly the same as I have
used here. Strange. Let me try to
pull it like so. It seems that at the
moment the tag 'latest', for some
reason is not assigned to any image
of 'elasticsearch' versions. And yes,
that is the case. And we need to
specify exact tag, either this one
or this one. Let me use this tag,
and let me modify command here. If
you got the same error, please
repeat this step along with me. So,
let's pull a specific image of
'elasticsearch'. Let me copy this
command, save this file by the
way, let me go back to terminal, and
paste the copied command like so.
Alright, now we are pulling image
from Docker Hub. It is strange
that 'latest' tag isn't available. I
don't know why for some reason.
Okay, image was finally downloaded,
and the new container was created,
and here I see SHA-1 hash of this
newly created container. Let me
verify whether it is running or not,
'docker ps'; and yes, I see that
'elasticsearch' container is now
currently running. Here is the
CONTAINER ID, here is IMAGE that
was used, it is image with custom
tag, and also you see here port
mapping, we have exposed port
9200 to outside, there was also
another port that the Elasticsearch
server listens to, it's 9300, but I
didn't ask you to expose it because
this port is usually used for
internal communication between
different Elasticsearch servers. At
the moment, we have only one
server. That's why there is no need
to expose this port outside.
Great. And here, I also see custom
name for this container. Let me now
start the 'curl' container. Let me
go back to those commands. And I'll
use this command. Let me copy it
from here, go back to terminal, and
paste it like so. Sorry, I have
forgotten to add here '-it'
options. All right. Let me try to
add them here in this file, '-it',
like so. Let me try to copy
this command over again, paste it
here, 'docker container prune', Yes.
[no audio]
Again, rerun this command. And now
I'm in 'sh' shell. Let me open up
web browser, and verify
connection to 'elasticsearch'. Recap
that we have exposed port 9200,
and I'm able to use a localhost here,
and port
9200.
[no audio]
'This page isn't working'. Let me go back to
terminal and verify again whether
server is running. And it seems
that it was exited. Let me verify
logs for this container, 'docker logs elasticsearch',
[no audio]
there are some logs
related to shutdown of the
Elasticsearch server, "stopping...'
[no audio]
Actually, I don't know the reason
why it stopped. Basically, let me
quickly go to official page for 'elasticsearch'
image, and check whether we
started correctly or not. 'Run
Elasticsearch'. Here is name, custom
network, okay two ports exposed, but
we basically don't needed the
second port, and here we see
additional environment variable
"discovery.type=single-node". Probably
that is the reason. Let me copy actually
this environment variable setting,
go to this command, and add it here
like so, let me save the file, and
now let me remove 'elasticsearch'
container that is running, and let
me start over new container. Let
me clear terminal, 'docker rm
elasticsearch', container was
removed. Let me copy this command.
Let me actually remove '-d' option
and start the 'elasticsearch'
container in foreground. Let me
copy this command, go here,
[no audio]
alright, information about OpenJDK
version. Elasticsearch actually
requires Java Development Kit to be
running in order to be able to start.
[no audio]
Some modules are being loaded right
now. Here is version 7.6.2. Starting.
Security disabled. Active
license is now [BASIC]. Alright, it
seems that now server is running.
Let me go back to Chrome, and
refresh page here.
And now I get result. And it
seems that the problem was in that
custom environment variable,
"discovery.type=single-node". All
right, now we have Elasticsearch
server running, and also we have
'curl' container running. Let me go to
'curl' container here, and let me
try to ping elasticsearch
container 'ping elasticsearch' like
so. And I get result. And that
means that we are now able to reach
Elasticsearch server by its name,
name of the container, elasticsearch;
and here is IP address that
was assigned to elasticsearch
container. Great. Now we're all set, and
next let's perform some actions
with Elasticsearch Server. Let's
create new index, and let's
insert some documents in that index,
and afterwards let's perform some
searches. I will see you next. Bye-Bye.
[no audio]