To build an image that is not available in the official Docker repository tags, or to add specific plugins to your image, you can create a custom Dockerfile.
The process varies depending on whether you want to build an image with Logstash 8.x
versions or Logstash 7.x
versions
Create this Dockerfile
to build an image with OpenSearch 2.0.2
for Logstash 8.x
ARG APP_VERSION
FROM docker.elastic.co/logstash/logstash-oss:${APP_VERSION}
RUN logstash-plugin install --version 7.1.1 logstash-integration-aws
RUN logstash-plugin install --version 2.0.2 logstash-output-opensearch
For Logstash 7.x
, the Logstash output OpenSearch gem needs to be build.
-
Clone
logstash-output-opensearch repo
git clone https://github.com/opensearch-project/logstash-output-opensearch.git
-
Checkout the tag for the plugin version you want to build. For the version 2.0.2 for example
git checkout 2.0.2
-
Remove this line that adds the json version spec. This version of the JSON gem is incompatible with
Logstash version 7.x
. -
Build the gem by running the following command:
gem build logstash-output-opensearch.gemspec
The Gemfile
logstash-output-opensearch-2.0.2-x86_64-linux.gem
will be generated.
Create this Dockerfile to build an image with logstash version 7.x
and the previously generated Gemfile
:
ARG APP_VERSION
FROM docker.elastic.co/logstash/logstash-oss:${APP_VERSION}
USER logstash
# Remove existing logstash aws plugins and install logstash-integration-aws to keep sdk dependency the same
# https://github.com/logstash-plugins/logstash-mixin-aws/issues/38
# https://github.com/opensearch-project/logstash-output-opensearch#configuration-for-logstash-output-opensearch-plugin
RUN logstash-plugin remove logstash-input-s3
RUN logstash-plugin remove logstash-input-sqs
RUN logstash-plugin remove logstash-output-s3
RUN logstash-plugin remove logstash-output-sns
RUN logstash-plugin remove logstash-output-sqs
RUN logstash-plugin remove logstash-output-cloudwatch
RUN logstash-plugin install --version 7.1.1 logstash-integration-aws
COPY logstash-output-opensearch-2.0.2-x86_64-linux.gem /usr/share
RUN logstash-plugin install /usr/share/logstash-output-opensearch-2.0.2-x86_64-linux.gem