Я пытаюсь собрать ELK в Docker, используя https://github.com/elastic/stack-docker
Но мне нужны только Elasticsearch, Kibana и Logstash, поэтому я удалил все файлы apm_server, filebeat и т. Д.
Затем выполните команду:
docker-compose -f setup.yml up
возвращает следующий вывод:
После этого каждая команда docker-compose выдает одну и ту же ошибку:
ОШИБКА: Именованный том "es_data:/usr/share/elasticsearch/data:rw"
используется в сервисе "elasticsearch"
, но в разделе томов не найдено объявлений.
Мой setup.yml
выглядит так:
version: "3.6"
services:
setup:
image: docker/compose:1.21.2
working_dir: "${PWD}"
cap_add: ['SYS_ADMIN']
environment:
- "PWD=${PWD}"
- "ELASTIC_PASSWORD"
- "ELASTIC_VERSION"
- "TAG"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "${PWD}:${PWD}"
entrypoint: ["/bin/ash", "-c"]
command: ['cat ./scripts/setup.sh | tr -d "\r" | ash']
# command: ["./scripts/setup.sh"]
И мой docker-compose.yml:
---
version: '3.6'
services:
# The environment variable "TAG" is used throughout this file to
# specify the version of the images to run. The default is set in the
# '.env' file in this folder. It can be overridden with any normal
# technique for setting environment variables, for example:
#
# TAG=6.0.0-beta1 docker-compose up
#
# REF: https://docs.docker.com/compose/compose-file/#variable-substitution
#
# Also be sure to set the ELASTIC_VERSION variable. For released versions,
# ${TAG} and ${ELASTIC_VERSION} will be identical, but for pre-release
# versions, ${TAG} might contain an extra build identifier, like
# "6.0.0-beta1-3eab5b40", so a full invocation might look like:
#
# ELASTIC_VERSION=6.0.0-beta1 TAG=6.0.0-beta1-3eab5b40 docker-compose up
#
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${TAG}
container_name: elasticsearch
secrets:
- source: ca.crt
target: /usr/share/elasticsearch/config/certs/ca/ca.crt
- source: elasticsearch.yml
target: /usr/share/elasticsearch/config/elasticsearch.yml
- source: elasticsearch.keystore
target: /usr/share/elasticsearch/config/elasticsearch.keystore
- source: elasticsearch.key
target: /usr/share/elasticsearch/config/certs/elasticsearch/elasticsearch.key
- source: elasticsearch.crt
target: /usr/share/elasticsearch/config/certs/elasticsearch/elasticsearch.crt
ports: ['9200:9200']
networks: ['stack']
volumes:
- 'es_data:/usr/share/elasticsearch/data'
- './scripts/setup-users.sh:/usr/local/bin/setup-users.sh:ro'
healthcheck:
test: curl --cacert /usr/share/elasticsearch/config/certs/ca/ca.crt -s https://localhost:9200 >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
interval: 30s
timeout: 10s
retries: 5
kibana:
image: docker.elastic.co/kibana/kibana:${TAG}
container_name: kibana
secrets:
- source: kibana.yml
target: /usr/share/kibana/config/kibana.yml
- source: kibana.keystore
target: /usr/share/kibana/data/kibana.keystore
- source: ca.crt
target: /usr/share/kibana/config/certs/ca/ca.crt
- source: kibana.key
target: /usr/share/kibana/config/certs/kibana/kibana.key
- source: kibana.crt
target: /usr/share/kibana/config/certs/kibana/kibana.crt
ports: ['5601:5601']
networks: ['stack']
depends_on: ['elasticsearch']
healthcheck:
test: curl --cacert /usr/share/elasticsearch/config/certs/ca/ca.crt -s https://localhost:5601 >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
interval: 30s
timeout: 10s
retries: 5
logstash:
image: docker.elastic.co/logstash/logstash:${TAG}
container_name: logstash
secrets:
- source: logstash.conf
target: /usr/share/logstash/pipeline/logstash.conf
- source: logstash.yml
target: /usr/share/logstash/config/logstash.yml
- source: logstash.keystore
target: /usr/share/logstash/config/logstash.keystore
- source: ca.crt
target: /usr/share/logstash/config/certs/ca/ca.crt
networks: ['stack']
depends_on: ['elasticsearch']
healthcheck:
test: bin/logstash -t
interval: 60s
timeout: 50s
retries: 5
secrets:
ca.crt:
file: ./config/ssl/ca/ca.crt
logstash.yml:
file: ./config/logstash/logstash.yml
logstash.keystore:
file: ./config/logstash/logstash.keystore
logstash.conf:
file: ./config/logstash/pipeline/logstash.conf
elasticsearch.yml:
file: ./config/elasticsearch/elasticsearch.yml
elasticsearch.keystore:
file: ./config/elasticsearch/elasticsearch.keystore
elasticsearch.key:
file: ./config/elasticsearch/elasticsearch.key
elasticsearch.crt:
file: ./config/elasticsearch/elasticsearch.crt
elasticsearch.p12:
file: ./config/elasticsearch/elasticsearch.p12
kibana.yml:
file: ./config/kibana/kibana.yml
kibana.keystore:
file: ./config/kibana/kibana.keystore
kibana.key:
file: ./config/kibana/kibana.key
kibana.crt:
file: ./config/kibana/kibana.crt