# Access logs inside docker container

**URL:** https://discuss.elastic.co/t/access-logs-inside-docker-container/147334
**Category:** Beats
**Tags:** filebeat
**Created:** [September 5, 2018, 8:11am UTC](https://discuss.elastic.co/t/access-logs-inside-docker-container/147334 "2018-09-05T08:11:45Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![prasanna12510](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@prasanna12510](https://discuss.elastic.co/u/prasanna12510)
#### Post date: [September 5, 2018, 8:11am UTC](https://discuss.elastic.co/t/access-logs-inside-docker-container/147334/1 "2018-09-05T08:11:46Z")

</div>

how to configure filebeat to ship logs inside the docker container running separately in same machine

---

<div class="post-metadata">

### Author: ![elk11](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@elk11](https://discuss.elastic.co/u/elk11)
#### Post date: [September 5, 2018, 10:09am UTC](https://discuss.elastic.co/t/access-logs-inside-docker-container/147334/2 "2018-09-05T10:09:39Z")

</div>

You'll have your container logs at: /var/lib/docker/containers/

Mount this path to some directory in your container ( -v /var/lib/docker/containers:usr/share/filebeat/dockerlogs) when you are deploying a filebeat container and then give use this path to configure your filebeat.

Here's the sample config file:

```
filebeat.prospectors:
- type: log
  enabled: true
  paths:
    - /usr/share/filebeat/dockerlogs/*/*.log
  encoding: plain
  fields:
    document_type: jenkins_container_log
  registry: /usr/share/filebeat/data/registry
  include_lines: ['failed']
  json.keys_under_root: true
  json.add_error_key: true
  json.message_key: log

setup.template:
  name: "filebeat"
  pattern: "filebeat-*"
  settings:
    index.number_of_shards: 1
    index.number_of_replicas: 1
output.elasticsearch:
  hosts: ["xxx:9200"]
  index: "filebeat-%{[fields.document_type]}-%{+yyyy.MM.dd}"
```

---

<div class="post-metadata">

### Author: ![prasanna12510](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@prasanna12510](https://discuss.elastic.co/u/prasanna12510)
#### Post date: [September 5, 2018, 10:19am UTC](https://discuss.elastic.co/t/access-logs-inside-docker-container/147334/3 "2018-09-05T10:19:29Z")

</div>

my application is running as container and I want to run filebeat as a different container. do I need to mount my container logs for eg: /var/log/supervisor/app.log(inside the container) on the host.

---

<div class="post-metadata">

### Author: ![elk11](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@elk11](https://discuss.elastic.co/u/elk11)
#### Post date: [September 5, 2018, 10:22am UTC](https://discuss.elastic.co/t/access-logs-inside-docker-container/147334/4 "2018-09-05T10:22:48Z")

</div>

I think you'll already have container logs on host in /var/lib/docker/containers. Mount this path to some directory on filebeat container.

---

<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: [October 3, 2018, 10:22am UTC](https://discuss.elastic.co/t/access-logs-inside-docker-container/147334/5 "2018-10-03T10:22:51Z")

</div>

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