All right.
I hope you were able to complete this challenge.
And now let's do the together and I'll first prepare our commands in VS code file.
I have already created the folder called Elasticsearch, and here inside there is already a file called
Elasticsearch dash commands dot 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 dot txt, same as we did for WordPress
and MySQL.
Examples commands, dot 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 elastic search container.
Elastic search container like.
So here I will use Docker run command.
I will use backslashes to separate different sub parts of the same command.
And next, let me give name to this container name.
Elastic search like so.
Next, I have asked you to create port mapping.
Here will be dash and external port will be 90 200.
Same as internal port 90 200 will expose same port to outside.
Next, let's specify here.
Name of the image and name will be elastic search 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 dash dash, network and name will be elastic search.
It is a name of this network we have created here above.
And it seems that that's all what I asked you to do.
Alright, next container will be container.
Create URL 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 see container docker run backslash network will be the same.
Let me copy this command from here.
Paste like so.
Next let's give it also name.
Does this name and name will be, let's say 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 command
that is hardcoded into this image and I want to override it with command or you are able to use bash
command as well, but I'll use 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 to 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 now run Elasticsearch container.
At the moment I don't have Elasticsearch image in local hash.
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.
Elastic search 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 tags.
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 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.
All right.
Now we are pulling image from Docker Hub.
It is strange that the latest tech 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 Sha1 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 in this image with custom tag.
And also you see here port mapping.
We have exposed port 92 002 outside.
There is also another port that Elasticsearch server listens to.
It is 90 300.
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 to see 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.
Dash options.
All right.
Let me try to add them here in.
This file.
This team like.
So let me try to copy this command over again.
Paste it here.
Docker Container Prune.
Yes.
Again, rerun this command.
And now I'm in hell.
Let me open up a web browser and verify connection to Elasticsearch.
Recap that we have exposed port 90 200 and I'm able to use localhost here.
And port.
90 200.
The 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.
There are some logs related to shutdown of the Elasticsearch server stopping.
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 need the second port.
And here you 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.
Option and start the Elasticsearch container in foreground.
Let me copy this command.
Go here.
All right.
Information about open JDK version.
Elasticsearch actually requires Java Development kit to be running in order to be able to start.
Some modules are being loaded right now.
Here is version.
762.
Starting.
Security disabled.
Active license is now basic.
All right.
It seems that now server is running.
Let me go back to Chrome and refresh page here.
And now I get a result.
And it seems that the problem was in that custom environment.
Variable discovery type single node.
All right.
Now we have elastic storage server running and also we have see container running.
Let me go to see container here and let me try to ping elasticsearch container ping, elastic search
like so and I get a result and that means that we are now able to reach elastic search server by its
name name of the container elastic search.
And here is IP address that was assigned to Elasticsearch container.
Great.
Now we are all set.
And the next let's perform some actions with Elasticsearch server.
Let's create a new index and let's insert some documents in that index.
And afterwards let's perform some searches.
I'll see you next.
Bye bye.