Docker starts the elasticsearch image and solves the error after mounting the directory

Docker starts the elasticsearch image and solves the error after mounting the directory

Downloaded an es image from docker hub, version 6.4.2, the details are as follows:

The more important ones are these two. The first is the working directory, and the mount directory also needs to correspond to this; the second is the startup command, where a pre-written startup script is specified. So I started an empty container to check what was going on inside it:

The directory structure inside the container is as shown above. Data is used to store data, and logs is used to store logs.

Next, check the startup script

/usr/local/bin/docker-entrypoint.sh

I only have a limited understanding of the first half, but the last part is really related to the mount directory. It deals with the operations after the mount directory, which roughly means:

If it is the root user (docker starts the container, the default is to start the container as the root user), and the TAKE_FILE_OWNERSHIP variable exists, then change the two directories /usr/share/elasticsearch/{data,logs} to belong to user 1000 (you can also see here that the final data storage path is data, so it should be mounted under data).

User with id 1000:

It is the elasticsearch user, so if you don't mount any directory, you can start the container directly. If you mount it, then add a variable and assign any value, and es can start normally.

docker run -itd -v /root/es-data/:/usr/share/elasticsearch/data -e TAKE_FILE_OWNERSHIP=111 -p 9200:9200 --name es elasticsearch:6.4.2

Supplementary knowledge: Record a docker installation of elasticsearch and the pitfalls encountered

First give a line of command

docker run -d -p 9200:9200 -p 9300:9300 -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" --name=<your es name> elasticsearch:<es version>

Use this command to directly install and run the es docker image container

question

Use the command docker run -d -p 9200:9200 -p 9300:9300 --name=<your es name> elasticsearch:<es version> to start, and then to see if it is started, use the docker ps command to find:

es did not start.

So I used the docker ps -a command again:

Found that the startup was terminated.

Then use the docker logs -f <container id> command to view the es startup log:

Scroll to the bottom:

It looks like this:

Power management:

Memory: 4k page, physical 1882892k(89076k free), swap 0k(0k free)

vm_info: OpenJDK 64-Bit Server VM (25.181-b13) for linux-amd64 JRE (1.8.0_181-8u181-b13-2~deb9u1-b13), built on Oct 22 2018 18:05:23 by "pbuilder" with gcc 6.3.0 20170516

time: Fri Nov 23 07:00:34 2018
elapsed time: 0 seconds (0d 0h 0m 0s)

So I copied the error message and Googled it, and found the problem. The default memory configuration for elasticsearch5.+ is 2g. I only gave docker 2g of memory, so it was GG.

After deleting the old container and the old image, add -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" to the docker startup command to solve the problem

docker ps :

Finally, visit port 9200:

OJ

The above article about how to solve the error after starting the elasticsearch image in docker and mounting the directory is all I want to share with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Solve the problem that Elasticsearch fails to start due to jdk version problems
  • Solve the problem of Docker starting Elasticsearch7.x and reporting an error
  • Insufficient memory problem and solution when docker starts elasticsearch
  • elasticsearch startup warning unable to lock JVM memory
  • Elasticsearch injects Node assembly startup process through guice

<<:  js realizes the magnifying glass effect of shopping website products

>>:  Rules for registration form design

Recommend

Detailed explanation of CocosCreator optimization DrawCall

Table of contents Preface What is DrawCall How do...

Solution to forget password when installing MySQL on Linux/Mac

Preface This article mainly introduces the releva...

Detailed explanation of incompatible changes of components in vue3

Table of contents Functional Components How to wr...

Pull-down refresh and pull-up loading components based on Vue encapsulation

Based on Vue and native javascript encapsulation,...

How to use ss command instead of netstat in Linux operation and maintenance

Preface When operating and managing Linux servers...

Solution to the Multiple primary key defined error in MySQL

There are two ways to create a primary key: creat...

HTML exceeds the text line interception implementation principle and code

The HTML code for intercepting text beyond multipl...

The shortest JS to determine whether it is IE6 (IE writing method)

Commonly used JavaScript code to detect which ver...

Vue3.0 handwriting magnifying glass effect

The effect to be achieved is: fixed zoom in twice...

Introduction to JWT Verification Using Nginx and Lua

Table of contents Preface Lua Script nignx.conf c...

Examples of using the ES6 spread operator

Table of contents What are spread and rest operat...

Vue component library ElementUI implements table loading tree data tutorial

ElementUI implements a table tree list loading tu...

A brief discussion on why daemon off is used when running nginx in docker

I'm very happy. When encountering this proble...