Install Elastic Search in a docker environment
By: Neeraj in ELKStack Tutorials on 2019-05-06
You can install Elastic Search in a docker environment. For this to work, you need to make sure that you have the docker installed in your environment (linux/windows/mac etc). Once the docker is installed, you also need to check whether docker-compose is installed. For Windows environment, docker-compose is usually bundled with your docker installation. But for linux, you need to explicitly install docker-compose. You can install docker-compose using the command. Use pip
to install.
pip install docker-compose
After you have installed docker-compose, create a file named docker-compose.yml with the below code:
version: '2.2' services: es01: image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1 container_name: es01 environment: - node.name=es01 - discovery.seed_hosts=es02 - cluster.initial_master_nodes=es01,es02 - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - esdata01:/usr/share/elasticsearch/data ports: - 9200:9200 networks: - esnet es02: image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1 container_name: es02 environment: - node.name=es02 - discovery.seed_hosts=es01 - cluster.initial_master_nodes=es01,es02 - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - esdata02:/usr/share/elasticsearch/data networks: - esnet volumes: esdata01: driver: local esdata02: driver: local networks: esnet:
The above yml defines two elastic search nodes running in port 9200 in a single cluster. Now you can install elastic search in your docker environment, using the below command.
docker-compose up
You can check whether the elastic search nodes are properly installed and running by connecting to your port 9200. You can do so using curl command.
curl http://127.0.0.1:9200/_cat/health 1472225929 15:38:49 docker-cluster green 2 2 4 2 0 0 0 0 - 100.0%
You can shut down the dockers running elastic search nodes by issuing the command:
docker-compose down
If you are getting this error: ERROR: for +es01 Cannot start service es01: driver failed programming external connectivity on endpoint es01
it means another instance of elastic search is already using the port 9200. So find that instance using "ps aux| grep elastic" and kill it. After that run docker-compose up again to start the nodes.
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in ELKStack ) |
Latest Articles (in ELKStack) |
- Data Science
- Android
- React Native
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
Comments