Create Logstash output files in a docker image

I'm trying to integrate my Logstash development project with Docker (I am quite new to Docker as well, so my knowledge of Docker is quite basic).
I am able to create an image with a simple Dockerfile and then successfully run the image with a basic logstash config file, however, I actually want my config file to do more than just stdout {} in console view. More exactly, I want to save the output of some filtered logs (with grok) in a JSON file, in a certain folder in that image. For this I added some code in the Dockerfile, but when I run the image, whenever it tries to execute the commands in the logstash config file I see this error, and then the JVM stops.

[2019-10-18T09:33:56,898][INFO ][logstash.outputs.file    ] Opening file {:path=>"/usr/share/logstash/data/logstashOUTPUT.json"}
[2019-10-18T09:33:56,906][ERROR][org.logstash.execution.WorkerLoop] Exception in pipelineworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash.
org.jruby.exceptions.SystemCallError: (EACCES) Permission denied - /usr/share/logstash/data/logstashOUTPUT.json

I assume that my Docker ADD is adding the file where I need, but when the output command from the logstash .conf file tries to write in the JSON file, the permission is not granted.
How can I fix this ?

Here is the content of my Docker file as well:

RUN rm -f /usr/share/logstash/pipeline/logstash.conf
#ADD pipelines.yml /usr/share/logstash/pipeline/
ADD logstashDocker.conf /usr/share/logstash/pipeline/
ADD logstashOUTPUT.json /usr/share/logstash/data/

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