C
C
Ciscoridze2018-05-25 20:43:09
linux
Ciscoridze, 2018-05-25 20:43:09

How to make a docker image in my case?

I want to change the finished image sebp/elk.
To do this, judging by the manual, you need a Dockerfile with the following content:

FROM sebp/elk
WORKDIR ${LOGSTASH_HOME}
RUN gosu logstash bin/logstash-plugin install logstash-input-rss

I need to add a module to the logstash, and if I go into the docker container exec -it bin/bash container_id and do:
service logstash stop
cd /opt/logstash
bin/logstash --modules netflow --setup -M netflow.var.input.udp.port=9966
service logstash start

I get what I need!
How can I make a ready-made image so that I make a container already with this setting?
I try like this:
FROM sebp/elk
  
WORKDIR ${LOGSTASH_HOME}
RUN gosu logstash bin/logstash --modules netflow --setup -M netflow.var.input.udp.port=9966

or like this:
WORKDIR ${LOGSTASH_HOME}
 RUN cd /opt/logstash \
   && bin/logstash --modules netflow --setup -M netflow.var.input.udp.port=9966

The result of this is the same:
Step 3/3 : RUN cd /opt/logstash   && bin/logstash --modules netflow --setup -M netflow.var.input.udp.port=9966
     ---> Running in e68f0025019d
    Sending Logstash's logs to /opt/logstash/logs which is now configured via log4j2.properties
    [2018-05-25T14:09:22,940][INFO ][logstash.modules.scaffold] Initializing module {:module_name=>"fb_apache", :directory=>"/opt/logstash/modules/fb_apache/configuration"}
    [2018-05-25T14:09:22,958][INFO ][logstash.modules.scaffold] Initializing module {:module_name=>"netflow", :directory=>"/opt/logstash/modules/netflow/configuration"}
    [2018-05-25T14:09:23,055][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.queue", :path=>"/opt/logstash/data/queue"}
    [2018-05-25T14:09:23,059][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.dead_letter_queue", :path=>"/opt/logstash/data/dead_letter_queue"}
    [2018-05-25T14:09:23,498][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
    [2018-05-25T14:09:23,533][INFO ][logstash.agent           ] No persistent UUID file found. Generating new UUID {:uuid=>"9de46a0c-dcba-4a3f-a86b-5f9c7f863c0d", :path=>"/opt/logstash/data/uuid"}
    [2018-05-25T14:09:24,214][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"6.2.3"}
    [2018-05-25T14:09:24,903][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
    [2018-05-25T14:09:25,582][ERROR][logstash.modules.kibanaclient] Error when executing Kibana client request {:error=>#<Manticore::SocketException: Connection refused (Connection refused)>}
    [2018-05-25T14:09:25,709][ERROR][logstash.modules.kibanaclient] Error when executing Kibana client request {:error=>#<Manticore::SocketException: Connection refused (Connection refused)>}
    [2018-05-25T14:09:25,876][ERROR][logstash.config.sourceloader] Could not fetch all the sources {:exception=>LogStash::ConfigLoadingError, :message=>"Failed to import module configurations to Elasticsearch and/or Kibana. Module: netflow has Elasticsearch hosts: [\"localhost:9200\"] and Kibana hosts: [\"localhost:5601\"]", :backtrace=>["/opt/logstash/logstash-core/lib/logstash/config/modules_common.rb:99:in `block in pipeline_configs'", "org/jruby/RubyArray.java:1734:in `each'", "/opt/logstash/logstash-core/lib/logstash/config/modules_common.rb:56:in `pipeline_configs'", "/opt/logstash/logstash-core/lib/logstash/config/source/modules.rb:16:in `pipeline_configs'", "/opt/logstash/logstash-core/lib/logstash/config/source_loader.rb:59:in `block in fetch'", "org/jruby/RubyArray.java:2481:in `collect'", "/opt/logstash/logstash-core/lib/logstash/config/source_loader.rb:58:in `fetch'", "/opt/logstash/logstash-core/lib/logstash/agent.rb:148:in `converge_state_and_update'", "/opt/logstash/logstash-core/lib/logstash/agent.rb:90:in `execute'", "/opt/logstash/logstash-core/lib/logstash/runner.rb:348:in `block in execute'", "/opt/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24:in `block in initialize'"]}
    [2018-05-25T14:09:25,888][ERROR][logstash.agent           ] An exception happened when converging configuration {:exception=>RuntimeError, :message=>"Could not fetch the configuration, message: Failed to import module configurations to Elasticsearch and/or Kibana. Module: netflow has Elasticsearch hosts: [\"localhost:9200\"] and Kibana hosts: [\"localhost:5601\"]", :backtrace=>["/opt/logstash/logstash-core/lib/logstash/agent.rb:155:in `converge_state_and_update'", "/opt/logstash/logstash-core/lib/logstash/agent.rb:90:in `execute'", "/opt/logstash/logstash-core/lib/logstash/runner.rb:348:in `block in execute'", "/opt/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24:in `block in initialize'"]}
    The command '/bin/sh -c cd /opt/logstash   && bin/logstash --modules netflow --setup -M netflow.var.input.udp.port=9966' returned a non-zero code: 1

I know that to run `bin/logstash --modules netflow --setup -M netflow.var.input.udp.port=9966`, kibana and elasticsearch, which are in the sebp/elk container, must be running. Judging by
"Failed to import module configurations to Elasticsearch and/or Kibana. Module: netflow has Elasticsearch hosts: [\"localhost:9200\"] and Kibana hosts: [\"localhost:5601\"]", :backtrace=>["/opt/logstash/logstash-core/lib/logstash/config/modules_common.rb:99:in `block in pipeline_configs'", "org/jruby/RubyArray.java:1734:in `each'", "/opt/logstash/logstash-core/lib/logstash/config/modules_common.rb:56:in `pipeline_configs'", "/opt/logstash/logstash-core/lib/logstash/config/source/modules.rb:16:in `pipeline_configs'", "/opt/logstash/logstash-core/lib/logstash/config/source_loader.rb:59:in `block in fetch'", "org/jruby/RubyArray.java:2481:in `collect'", "/opt/logstash/logstash-core/lib/logstash/config/source_loader.rb:58:in `fetch'", "/opt/logstash/logstash-core/lib/logstash/agent.rb:148:in `converge_state_and_update'", "/opt/logstash/logstash-core/lib/logstash/agent.rb:90:in `execute'", "/opt/logstash/logstash-core/lib/logstash/runner.rb:348:in `block in execute'", "/opt/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24:in `block in initialize'"]}
    [2018-05-25T14:09:25,888][ERROR][logstash.agent           ] An exception happened when converging configuration {:exception=>RuntimeError, :message=>"Could not fetch the configuration, message: Failed to import module configurations to Elasticsearch and/or Kibana. Module: netflow has Elasticsearch hosts: [\"localhost:9200\"] and Kibana hosts: [\"localhost:5601\"]", :backtrace=>["/opt/logstash/logstash-core/lib/logstash/agent.rb:155:in `converge_state_and_update'", "/opt/logstash/logstash-core/lib/logstash/agent.rb:90:in `execute'", "/opt/logstash/logstash-core/lib/logstash/runner.rb:348:in `block in execute'", "/opt/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24:in `block in initialize'"]}
    The command '/bin/sh -c cd /opt/logstash   && bin/logstash --modules netflow --setup -M netflow.var.input.udp.port=9966' returned a non-zero code: 1

Maybe a nuance in this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Moseychuk, 2018-05-28
@fshp

RUN is used when creating an image. Your actions must be performed when starting the container. Read the documentation for CMD and ENTRYPOINT.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question