Elasticsearch - starting in a docker container
Using docker-compose:
docker-compose --file docker-compose-elasticsearch-7.17.3.yml up -d
Using docker command:
To start elasticsearch version 7.10.0.
docker run -p 9200:9200 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.10.0
However, the latest versions of the plugin for spring applications seem to have trouble working with older versions of elasticsearch. See error1.org
Running this command will start an Elasticsearch instance listening on port 9200. We can verify the instance state by hitting the URL http://localhost:9200 and check the resulting output in our browser:
{
"name" : "bb2fb59c20bb",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "dqKAevNvTZCzEIenMYXISw",
"version" : {
"number" : "7.10.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "51e9d6f22758d0374a0f3f5c6e8f3a7997850f96",
"build_date" : "2020-11-09T21:30:33.964949Z",
"build_snapshot" : false,
"lucene_version" : "8.7.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
elasticsearch 8.8.1
Elasticsearch 8 comes with SSL/TLS enabled by default. Disable security with the environment variable xpack.security.enabled=false
. If security remains enabled, configuring the Elasticsearch client will require setting up a proper SSL connection.
docker run -p 9200:9200 -e "discovery.type=single-node" -e "xpack.security.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:8.8.1
To start Kibana:
docker pull docker.elastic.co/kibana/kibana:8.11.3
docker run --name kibana -p 5601:5601 docker.elastic.co/kibana/kibana:8.11.3
To start elasticsearch version 8.11.3
https://www.elastic.co/guide/en/elasticsearch/reference/current/run-elasticsearch-locally.html
Step 1: Start Elasticsearch. Take note of the passwords and tokens.
docker network create elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.11.3
docker run --name elasticsearch --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -t docker.elastic.co/elasticsearch/elasticsearch:8.11.3
This has security configured by default. So, the url http://localhost:9200 will not work. Follow the instructions from elasticsearch web page for accessing the UI.
The output will have something similar to this:
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.
ℹ️ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
qeaP+P6sEJINJRKu7usd
ℹ️ HTTP CA certificate SHA-256 fingerprint:
55f8d706125b0a54896e7e457842e1d4a036a8cb413199de3489a38d701016b0
ℹ️ Configure Kibana to use this cluster:
• Run Kibana and click the configuration link in the terminal when Kibana starts.
• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjExLjMiLCJhZHIiOlsiMTcyLjE5LjAuMjo5MjAwIl0sImZnciI6IjU1ZjhkNzA2MTI1YjBhNTQ4OTZlN2U0NTc4NDJlMWQ0YTAzNmE4Y2I0MTMxOTlkZTM0ODlhMzhkNzAxMDE2YjAiLCJrZXkiOiJHanZiMVl3Qm1oU2xtT184ZUZmTjpJckJOTlh4QVNoYWNFNjRwTGdLejF3In0=
ℹ️ Configure other nodes to join this cluster:
• Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjExLjMiLCJhZHIiOlsiMTcyLjE5LjAuMjo5MjAwIl0sImZnciI6IjU1ZjhkNzA2MTI1YjBhNTQ4OTZlN2U0NTc4NDJlMWQ0YTAzNmE4Y2I0MTMxOTlkZTM0ODlhMzhkNzAxMDE2YjAiLCJrZXkiOiJIRHZiMVl3Qm1oU2xtT184ZUZmbjpnNlJPOUlDLVI5R3I1aTdWQzZhZ29BIn0=
If you're running in Docker, copy the enrollment token and run:
`docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.11.3`
Step 2: Start Kibana.
docker pull docker.elastic.co/kibana/kibana:8.11.3
docker run --name kibana --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.11.3
Launch the endpoint that is displayed in the logs in a browser. Username for elasic is “elastic”. Password will be available in elasticsearch logs.
Then, access elasticsearch through Kibana UI.