How to set volume map for logstash.conf file in docker compose file

Hello, I am trying to setup a docker compose file for setting up ELK stack to be able to use logging on local machine.

Below is the error shown in the terminal window, my stack is windows 11 home, Docker Engine v24.0.7, PowerShell v7.4.0
Can anyone guide on how to map volume so as to override default logstash.conf?
Let me know if you need further info regarding this query.

I am using below docker compose file

services:
  elasticsearch:
   container_name: elasticsearch
   image: docker.elastic.co/elasticsearch/elasticsearch:8.11.3
   ports:
    - 9200:9200
   environment:
    - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    - discovery.type=single-node
  kibana:
   container_name: kibana
   image: docker.elastic.co/kibana/kibana:8.11.3
   ports:
    - 5601:5601
   depends_on:
    - elasticsearch
   environment:
    - ELASTICSEARCH_URL=http://localhost:9200
  logstash:
    container_name: logstash
    image: docker.elastic.co/logstash/logstash:8.11.3
    depends_on:
      - elasticsearch
    volumes:
      - C:/D/Log/ELK/logstash.conf=/usr/share/logstash/pipeline/logstash.conf

Below is my logstash.conf file

input
{
    http {
        #default host 0.0.0.0:8080
        codec => json
    }
}
output {
    stdout { }
    elasticsearch {
        hosts => ["http://elastic:9200"]
    }
}

In case anyone else comes across this issue then the solution is to use below section for volumes in the compose.yml file.

Note: local machine path is relative to where the docker compose up -d command is run from.
In my case, I was running the command from C:/D/Log/ELK folder in PowerShell. Therefore, replaced that part with ./
Also, for mapping to work we need to use : instead of =

volumes:
      - ./logstash.conf:/usr/share/logstash/pipeline/logstash.conf

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.