# Enabling nginx module in filebeat on docker

**URL:** <https://discuss.elastic.co/t/enabling-nginx-module-in-filebeat-on-docker/143256>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [August 7, 2018, 7:26am UTC](https://discuss.elastic.co/t/enabling-nginx-module-in-filebeat-on-docker/143256 "2018-08-07T07:26:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![g.myznikov.tinkoff](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/g.myznikov.tinkoff/32/33582_2.png) [@g.myznikov.tinkoff](https://discuss.elastic.co/u/g.myznikov.tinkoff)\
**Post date:** [August 7, 2018, 7:26am UTC](https://discuss.elastic.co/t/enabling-nginx-module-in-filebeat-on-docker/143256/1 "2018-08-07T07:26:47Z")

</div>

Hello!  
I have run filebeat on docker by a custom image. Its Dockerfile is:

```auto
FROM docker.elastic.co/beats/filebeat:6.3.1
COPY filebeat.yml /usr/share/filebeat/filebeat.yml
USER root
RUN filebeat modules enable nginx
RUN filebeat setup
```

It is obviously that I try to enable nginx module. [http://localhost:5601/app/kibana#/home/tutorial/nginxLogs?\_g=()](http://localhost:5601/app/kibana#/home/tutorial/nginxLogs?_g=()) is my tutorial. Starting docker conteiner seems to work but nginx module stays disable. Any thoughts about what I've done wrong.  
P.S.  
My filebeat.yml:

```auto
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /testvar/*log
    - /testvar/**/*log

filebeat.config:
  modules:
    path: /usr/share/filebeat/modules.d/*.yml

output.elasticsearch:
  hosts: ["localhost:9200"]

setup.kibana:
  host: "localhost:5601"

```

---

<div class="post-metadata">

**Author:** ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)\
**Post date:** [August 7, 2018, 9:37am UTC](https://discuss.elastic.co/t/enabling-nginx-module-in-filebeat-on-docker/143256/2 "2018-08-07T09:37:31Z")

</div>

Hi @g.myznikov.tinkoff,

You shouldn't need to create a custom image. You can mount the configuration files on runtime with the `--volume` or `--mount` flags of `docker run`, this way you can provide a custom `filebeat.yml`, and also additional modules configuration, what could include modules enabling.

`filebeat setup` should be run only once, from a machine with access to elasticsearch and kibana, take into account that `RUN` commands in Dockerfiles are only run when the image is built.

Other thing you can try when using docker is [autodiscover and hints-based configuration](https://www.elastic.co/blog/docker-and-kubernetes-hints-based-autodiscover-with-beats), these features allow to enable and configure modules dynamically depending on a set of rules and the container settings, so you don't need to include static configurations in your configuration files.

---

<div class="post-metadata">

**Author:** ![g.myznikov.tinkoff](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/g.myznikov.tinkoff/32/33582_2.png) [@g.myznikov.tinkoff](https://discuss.elastic.co/u/g.myznikov.tinkoff)\
**Post date:** [August 7, 2018, 12:10pm UTC](https://discuss.elastic.co/t/enabling-nginx-module-in-filebeat-on-docker/143256/3 "2018-08-07T12:10:50Z")

</div>

Thanks for your answer. I've used your advice about including all information about modules in filebeat.yml. And now everthing seems to work fine. My filebeat.yml is:

```auto
filebeat.modules:
- module: nginx
  access:
    var.paths: ["/testvar/nginx/access.log"]
  error:
    var.paths: ["/testvar/nginx/error.log"]

output.elasticsearch:
  hosts: ["localhost:9200"]

setup.kibana:
  host: "localhost:5601"
```

And command for starting conteiner:

```auto
docker run -it --user=root -v /dockerfilebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml -v /var/log:/testvar docker.elastic.co/beats/filebeat:6.3.1
```

---

<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:** [September 4, 2018, 12:11pm UTC](https://discuss.elastic.co/t/enabling-nginx-module-in-filebeat-on-docker/143256/4 "2018-09-04T12:11:02Z")

</div>

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