# Install dependencies in the docker container

**URL:** <https://discuss.elastic.co/t/install-dependencies-in-the-docker-container/186506>\
**Category:** Logstash\
**Tags:** docker\
**Created:** [June 19, 2019, 3:10pm UTC](https://discuss.elastic.co/t/install-dependencies-in-the-docker-container/186506 "2019-06-19T15:10:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.heuberger](https://avatars.discourse-cdn.com/v4/letter/t/e8c25b/32.png) [@thomas.heuberger](https://discuss.elastic.co/u/thomas.heuberger)\
**Post date:** [June 19, 2019, 3:10pm UTC](https://discuss.elastic.co/t/install-dependencies-in-the-docker-container/186506/1 "2019-06-19T15:10:41Z")

</div>

I'm new to docker and I'm struggling a bit with installing the required prerequisites.  
I have this in my docker-composer.yml file, because I need the sflow plugin and I need the mysql jdbc driver:

```
command: >
  bash -c "export http_proxy='http://proxy:3128' &&
           export https_proxy=$http_proxy &&
           export JRUBY_OPTS='-J-Dhttp.proxyHost=proxy -J-Dhttp.proxyPort=3128' &&
           DEBUG=1 JARS_SKIP='true' &&
           bin/logstash-plugin install logstash-codec-sflow &&
           yum install -y mysql-connector-java &&
           bin/logstash"
user: root

```

This looks extremely unelegant to me as it is executed every time I run `docker-compose up`.

Is there no way to install the required dependencies just once and persist them? If I drop into an interactive shell, install what's needed, then everything is gone when I run `docker-compose down`.

---

<div class="post-metadata">

**Author:** ![Kevin\_Taylor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kevin_taylor/32/49805_2.png) [@Kevin\_Taylor](https://discuss.elastic.co/u/Kevin_Taylor)\
**Post date:** [July 10, 2019, 3:43pm UTC](https://discuss.elastic.co/t/install-dependencies-in-the-docker-container/186506/2 "2019-07-10T15:43:25Z")

</div>

I'm pretty new to Docker too, but I understand one way to do this is by creating a docker image. Basically you build the image (based on a specific 'logstash' dockerfile) and do the plugin install etc as part of that script. Once this is done you reference the image from your compose setup.

e.g. in docker file do something like this ..

COPY ./plugins/logstash-filter-myfilter-0.0.1.gem /usr/share/logstash/plugins/logstash-filter-myfilter-0.0.1.gem

RUN /usr/share/logstash/bin/logstash-plugin install --no-verify --local /usr/share/logstash/plugins/logstash-filter-myfilter-0.0.1.gem

build the image

docker build -f logstash.Dockerfile -t myimage .

and then in your compose yml file

logstash:  
image: myimage

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 7, 2019, 3:55pm UTC](https://discuss.elastic.co/t/install-dependencies-in-the-docker-container/186506/3 "2019-08-07T15:55:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
