-1

I want an image with elasticsearch and zipkin in it but i dont want to download it from docker hub instead I have downloaded the tar.gz file of those and then creating those images. I am able to run both of them individually but not simultaneously (by docker run command). Please see below Dockerfile

    FROM openjdk:11

    RUN groupadd -g 1000 elk-zipkin && useradd elk-zipkin -u 1000 -g 1000

    RUN mkdir /usr/share/elasticsearch/
    RUN mkdir /usr/share/zipkin
    #RUN mkdir /usr/share/kibana
    COPY /artifacts/elasticsearch-7.17.6.tar.gz /usr/share/elasticsearch
    COPY artifacts/zipkin.jar /usr/share/zipkin
    #COPY /artifacts/kibana-7.17.6.tar.gz /usr/share/kibana
    COPY script.sh /usr/share/zipkin

    WORKDIR /usr/share/elasticsearch
    RUN tar xvf elasticsearch-7.17.6.tar.gz
    #RUN tar xvf kibana-7.17.6.tar.gz

    WORKDIR /usr/share/elasticsearch/elasticsearch-7.17.6
    RUN set -ex && for path in data logs config config/scripts; do \
        mkdir -p "$path"; \
        chown -R elk-zipkin:elk-zipkin "$path"; \
    done

    USER elk-zipkin

    ENV PATH=$PATH:/usr/share/elasticsearch/elasticsearch-7.17.6/bin

    WORKDIR /usr/share/elasticsearch/elasticsearch-7.17.6/config
    #RUN sed -i "s|#network.host: 192.168.0.1|network.host: 0.0.0.0|g" elasticsearch.yml
    #RUN sed -i "s|#discovery.seed_hosts: ["host1", "host2"]|discovery.type: single-node|g"    elasticsearch.yml
    COPY /artifacts/elasticsearch.yml /usr/share/elasticsearch/elasticsearch-7.17.6/config

    #CMD ["elasticsearch"]

    #EXPOSE 9200 9300

    #WORKDIR /usr/share/zipkin

    #CMD ["java","-jar","zipkin.jar"]
    #EXPOSE 9411

    WORKDIR /usr/share/zipkin
    CMD ["sh","script.sh"]

script.sh: java -jar zipkin.jar elasticsearch

Run command for them:

  1. for zipkin - docker run -d --name=zipkin \ -p=9411:9411 \ --env=STORAGE_TYPE="elasticsearch" \ --env=ES_HOSTS="someurl" IMAGEID

  2. for elasticsearch - docker run -d --name=elasticsearch1 -p=9200:9200 -p=9300:9300 IMAGEID

I have tried to run both of the service i.e. elasticsearch and zipkin individually and simultaneously. I am expecting that both should be in one image and by only single docker run command both of the services should get run.

  • In order to achieve this, a "normal" OS would run something called a process manager, and using those in Docker is somehow an anti-pattern to the goal of having containers only do one task. The solutions to this are explained in the documentation, though: https://docs.docker.com/config/containers/multi-service_container/ – β.εηοιτ.βε Nov 24 '22 at 09:29
  • 1
    A Docker container is a wrapper around a single process. If you need multiple services running, the standard approach is to run them in multiple containers. Once you're doing that, they can also run based off of separate images. That setup should be easier to build, run, and keep up-to-date compared to what you're proposing here. – David Maze Nov 24 '22 at 11:57

1 Answers1

0

Somehow I made it, one can create a Dockerfile like mentioned in the question and then have to pass some sleep time into the script file to give some extra time for getting up the previous services. Example:

nohup elasticsearch &
sleep 10
nohup java -jar zipkin.jar

Note: As per comments and the basics of container, one should not create multiple services inside the same container.