0

i am a newby in docker and I need an installation based on ubuntu of logstash. I try the official logstash image and without success I can't run it so I decided to build my own installation based on my needs.

It works well but takes a lot of time to build it.

I wonder how can I improve (speed up) my building

This is my Dockerfile

FROM ubuntu:18.04

# RUN adduser --disabled-password --gecos "" ubuntu
# RUN usermod -aG sudo ubuntu

# RUN echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

RUN apt-get update && \
    apt-get autoclean && \
    apt-get autoremove
RUN echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-7.x.list
RUN apt-get install curl ca-certificates apt-utils wget  apt-transport-https default-jre gnupg apt-transport-https software-properties-common -y

# RUN update-alternatives --config java

ENV LANG C.UTF-8

ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
ENV PATH $JAVA_HOME/bin:$PATH


RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -


RUN apt update
RUN apt install ruby-full -y

RUN ruby --version

RUN apt install jruby -y
#install jruby (last version)
RUN jruby --version



RUN apt install logstash
#install plugins and bundles.
RUN cd /usr/share/logstash && gem install bundler
COPY logstash-pcap-test.conf /usr/share/logstash/
RUN mkdir /home/logstash/ && mkdir /home/logstash/traffic
COPY /traffic-example/*  /home/logstash/traffic/
WORKDIR /usr/share/logstash

CMD ["/bin/bash","-c","bin/logstash -f logstash-pcap-test.conf --config.reload.automatic"]

And this is my docker-compose

version: "3"
services:
  logstash_test:
    build:
      context: .
      dockerfile: container/Dockerfile
    image: logstash_test:latest
    container_name: logstash_test
    hostname: logstash_test
    ports:
      - 9600:9600
      - 8089:8089
    networks:
      - elknetwork
networks:
  elknetwork:
    driver: bridge

Any thoughts?

aepelman
  • 311
  • 2
  • 12
  • 1
    what problem are you facing when using the official image? – Stefano Oct 01 '20 at 12:34
  • What does this container actually do; why do you need a JRE and two different versions of Ruby, in addition to Logstash? – David Maze Oct 01 '20 at 12:52
  • @Stefano the official image hasn't the folder configuration needed, it doesn't exist /usr/share/logstash folder and also i can't run ``bin/logstash`` command it throws some configuration issues. – aepelman Oct 01 '20 at 13:00
  • @DavidMaze Logstash needs Java and Ruby for working they were requested for running my logstash script I think some of the logstash plugins works with them. – aepelman Oct 01 '20 at 13:01
  • You can [extend the official images](https://stackoverflow.com/a/22906654/1423507) with the configuration or [bind mount](https://docs.docker.com/storage/bind-mounts/) the configuration at runtime. [Here is a full ELK stack example running in `docker-compose`](https://stackoverflow.com/a/58556254/1423507) that ships `docker` containers logs to ELK if that could help. – masseyb Oct 01 '20 at 15:47

0 Answers0