Getting the following error while running lostash with docker

Errno::EACCES: Permission denied - /output
mkdir at org/jruby/RubyDir.java:458
fu_mkdir at /opt/logstash/vendor/jruby/lib/ruby/1.9/fileutils.rb:247
mkdir_p at /opt/logstash/vendor/jruby/lib/ruby/1.9/fileutils.rb:221
reverse_each at org/jruby/RubyArray.java:1693
mkdir_p at /opt/logstash/vendor/jruby/lib/ruby/1.9/fileutils.rb:219
each at org/jruby/RubyArray.java:1613
mkdir_p at /opt/logstash/vendor/jruby/lib/ruby/1.9/fileutils.rb:205
open at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-file-2.2.5/lib/logstash/outputs/file.rb:253
write_event at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-file-2.2.5/lib/logstash/outputs/file.rb:162
call at org/jruby/RubyProc.java:281
encode at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-codec-json_lines-2.1.3/lib/logstash/codecs/json_lines.rb:48
receive at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-file-2.2.5/lib/logstash/outputs/file.rb:129
multi_receive at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.3-java/lib/logstash/outputs/base.rb:83
each at org/jruby/RubyArray.java:1613
multi_receive at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.3-java/lib/logstash/outputs/base.rb:83
worker_multi_receive at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.3-java/lib/logstash/output_delegator.rb:130
multi_receive at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.3-java/lib/logstash/output_delegator.rb:114
output_batch at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.3-java/lib/logstash/pipeline.rb:301
each at org/jruby/RubyHash.java:1342
output_batch at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.3-java/lib/logstash/pipeline.rb:301
worker_loop at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.3-java/lib/logstash/pipeline.rb:232
start_workers at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.3-java/lib/logstash/pipeline.rb:201"

Already the permission are set using chmod 0777 for the output directory . Running logstash in docker container .

Command used for running logstash in docker.

sudo docker run -it --rm -v "$PWD":<cofig_file_path> logstash logstash -f /<config_file_path>/logstash.conf

Logstash.conf file:

input {
beats {
port => 5044
}
}

filter {
mutate {
remove_field => [ "beat", "count", "host", "year", "month", "day", "path", "@version", "tags", "input_type", "type" ]
}
}

output {
stdout { codec => rubydebug }
file {
path => "output/2.txt"
}
}

Please edit your post and move it to the Logstash category where it belongs.

I'm somewhat puzzled since the Logstash process you're starting in the container effectively runs as root, and it should be able to create /output inside the container.

However, that's not really what you want to happen right? It seems your expectation is to use the output subdirectory of the current directory, but that won't work as you've written things. You need to use the -w to start a container in a particular directory.

I've moved the category to logstash.

Yes , we want to create the output directory inside the container . But its throwing the error.

sudo docker run -w -it --rm -v "$PWD": logstash logstash -f //logstash.conf , adding -w whether it will write the output to current directory (adding -w),

Yes , we want to create the output directory inside the container

I still don't understand where you want the output file. Two options, pick out of them:

  • In /output. Then use an absolute path in the file output's path option.
  • In the output subdirectory of the directory from which you start the container. Then use the -w option to docker run so set the working directory of the container. That said, I'd general avoid using relative paths in Logstash configurations.

sudo docker run -w -it --rm -v "$PWD": logstash logstash -f //logstash.conf , adding -w whether it will write the output to current directory (adding -w),

The -w option takes a string argument, e.g. -w /path/to/some/dir. And why do you have double slashes in front of "logstash.conf"?

I tried with absolute path also but it was giving same error permission denied. There is no // before logstash.

I'll try with -w option , i understand this will not log the output to the docker instead it will log in to the current directory where i run the docker.

This topic was automatically closed after 21 days. New replies are no longer allowed.