docker run --rm -t -a stdout --name nginx -v $PWD/config/:/etc/nginx/:ro nginx:latest nginx -c /etc/nginx/nginx.conf -t
docker
Docker cannot start Elasticsearch
If you run Elasticsearch in docker, you’ll probably run into the same issue as mine
ERROR: [1] bootstrap checks failed
elasticsearch_1 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
To fix this, just run the following command:
sudo sysctl -w vm.max_map_count=262144
Run Elastic and Kibana using Docker
Docker engine and docker compose is the fastest way to try out Elastic and Kibana together
# Need to change this setup, otherwise elastic will fail and exit with code 78 sudo sysctl -w vm.max_map_count=262144
Create a docker-compose.yml
file in any folder
version: '2.2' services: es01: image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0 container_name: es01 environment: - node.name=es01 - cluster.name=es-docker-cluster - discovery.seed_hosts=es02,es03 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - data01:/usr/share/elasticsearch/data ports: - 9200:9200 networks: - elastic es02: image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0 container_name: es02 environment: - node.name=es02 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01,es03 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - data02:/usr/share/elasticsearch/data ports: - 9201:9201 networks: - elastic es03: image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0 container_name: es03 environment: - node.name=es03 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01,es02 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - data03:/usr/share/elasticsearch/data ports: - 9202:9202 networks: - elastic kib01: image: docker.elastic.co/kibana/kibana:7.10.0 container_name: kib01 ports: - 5601:5601 environment: ELASTICSEARCH_URL: http://es01:9200 ELASTICSEARCH_HOSTS: http://es01:9200 networks: - elastic volumes: data01: driver: local data02: driver: local data03: driver: local networks: elastic: driver: bridge
Next, let’s run and test
# Run this docker-compose up curl -X GET "localhost:9200/_cat/nodes?v&pretty" # And then visit this url: http://localhost:5601/app/kibana_overview#/
Install docker and docker-compose on Linux
The following commands help you install both docker
and docker-compose
at the same time, and also setup for the current user to run docker properly:
sudo apt-get remove docker docker-engine docker.io containerd runc sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io sudo usermod -aG docker $USER docker run hello-world sudo systemctl enable docker sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
Run MySQL using Docker
docker pull mysql/mysql-server docker images docker run --name=mysql1 --restart on-failure -d mysql/mysql-server:latest docker logs mysql1 docker logs mysql1 2>&1 | grep GENERATED GENERATED ROOT PASSWORD: Axegh3kAJyDLaRuBemecis&EShOs docker exec -it mysql1 mysql -uroot -p docker stop mysql1 docker restart mysql1 docker rm mysql1
You can get mysql password in docker using the log command as above
Install Docker on Linux using Terminal
sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo apt-key fingerprint 0EBFCD88 sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io sudo systemctl enable docker sudo docker run hello-world sudo groupadd docker sudo usermod -aG docker $USER newgrp docker docker run hello-world