在Docker容器外执行logstash命令

时间:2019-02-12 10:53:26

标签: docker elasticsearch logstash kibana

我想执行Logstash命令以开始导入到Elasticsearch,而无需进入ELK Docker容器。

这不起作用:

docker exec -it docker_elk_1 opt/logstash/bin/logstash -f /home/configs/logstash-logs.config

虽然会显示 Successfully started Logstash API endpoint {:port=>9600},但之后会退出。

但是,这可行,但是我必须先输入docker容器

docker exec -it docker_elk_1 bin/bash

然后

opt/logstash/bin/logstash -f /home/configs/logstash-logs.config

谢谢

docker-compose.yml

elk:
  image: sebp/elk
  volumes:
      - ${PWD}:/home/configs
  ports:
    - "5601:5601"
    - "9200:9200"
    - "5044:5044"

1 个答案:

答案 0 :(得分:0)

我不知道我是否理解...可以尝试:

docker exec -it docker_elk_1 /bin/bash -c 'opt/logstash/bin/logstash -f /home/configs/logstash-logs.config'

docker-compose exec /bin/bash -c 'opt/logstash/bin/logstash -f /home/configs/logstash-logs.config'