# Issue with Metricbeat Docker Container

**URL:** <https://discuss.elastic.co/t/issue-with-metricbeat-docker-container/109525>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [November 29, 2017, 7:26am UTC](https://discuss.elastic.co/t/issue-with-metricbeat-docker-container/109525 "2017-11-29T07:26:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rehan](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@rehan](https://discuss.elastic.co/u/rehan)\
**Post date:** [November 29, 2017, 7:26am UTC](https://discuss.elastic.co/t/issue-with-metricbeat-docker-container/109525/1 "2017-11-29T07:26:40Z")

</div>

Hi,

I am using metricbeat and I want to use metricbeat agent as docker container. I followed the link provided by [elastic.co](http://elastic.co)..

[https://www.elastic.co/guide/en/beats/metricbeat/current/running-on-docker.html](https://www.elastic.co/guide/en/beats/metricbeat/current/running-on-docker.html)

This documentation is totally confusing.  
After working for a long time, I found I need to provide my custom metricbeat.yml file.

@elastic -team, please correct the docker run command for the above link.If you have provided something then it should be correct.

The following command provided in the command is wrong.Please verify and correct.

docker run   
--volume=/proc:/hostfs/proc:ro \  
--volume=/sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro \  
--volume=/:/hostfs:ro \  
--net=host  
[docker.elastic.co/beats/metricbeat:6.0.0](http://docker.elastic.co/beats/metricbeat:6.0.0) -system.hostfs=/hostfs

My issues:

After providing custom yml file,I am able to get only system metrics but not docker metrics.Please find my yml file...

###################### Metricbeat Configuration Example #######################

# This file is an example configuration file highlighting only the most common

# options. The metricbeat.full.yml file from the same directory contains all the

# supported options with more comments. You can use it as a reference.

# 

# You can find the full configuration reference here:

# [https://www.elastic.co/guide/en/beats/metricbeat/index.html](https://www.elastic.co/guide/en/beats/metricbeat/index.html)

#========================== Modules configuration ============================  
metricbeat.modules:

#------------------------------- System Module -------------------------------

- module: system  
metricsets:

- module: docker  
metricsets: ["container", "cpu", "diskio","image", "healthcheck", "info", "memory", "network"]  
hosts: ["unix:///var/run/docker.sock"]  
period: 10s

#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group

# all the transactions sent by a single shipper in the web interface.

#name:

# The tags of the shipper are included in their own field with each

# transaction published.

#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the

# output.

#fields:

# env: staging

#================================ Outputs =====================================

# Configure what outputs to use when sending the data collected by the beat.

# Multiple outputs may be used.

#-------------------------- Elasticsearch output ------------------------------  
output.elasticsearch:

# Array of hosts to connect to.

hosts: ["localhost:9200"]

# Optional protocol and basic auth credentials.

#protocol: "https"  
#username: "elastic"  
#password: "changeme"

#----------------------------- Logstash output --------------------------------  
#output.logstash:

# The Logstash hosts

#hosts: ["x.x.x.x:5044"]

# Optional SSL. By default is off.

# List of root certificates for HTTPS server verifications

#ssl.certificate\_authorities: ["/etc/pki/root/ca.pem"]

# Certificate for SSL client authentication

#ssl.certificate: "/etc/pki/client/cert.pem"

# Client Certificate Key

#ssl.key: "/etc/pki/client/cert.key"

#================================ Logging =====================================

# Sets log level. The default log level is info.

# Available log levels are: critical, error, warning, info, debug

logging.level: debug

# At debug level, you can selectively enable logging only for some components.

# To enable all selectors use ["\*"]. Examples of other selectors are "beat",

# "publish", "service".

#logging.selectors: ["\*"]

I am getting en error in the Kibana. Please find the error message:

error.message:Get [http://unix.sock/containers/json?:](http://unix.sock/containers/json?:) dial unix /var/run/docker.sock: connect: no such file or directory @timestamp:November 29th 2017, 12:35:46.668 metricset.host:/var/run/docker.sock metricset.rtt:205 metricset.module:docker [metricset.name](http://metricset.name):cpu [beat.name](http://beat.name):ip-172-x.x.x beat.hostname:ip-172-x.x.x beat.version:6.0.0 \_id:AWAGmIUl26-ciqSLjq5g \_type:doc \_index:metricbeat-6.0.0-2017.1.

I belive that docker module is not able to connect the docker socket.  
Please help to fix the issue.

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [November 29, 2017, 10:44am UTC](https://discuss.elastic.co/t/issue-with-metricbeat-docker-container/109525/2 "2017-11-29T10:44:18Z")

</div>

Hi @rehan,

The problem is that Metricbeat doesn't have access to your `/var/run/docker.sock`, you have to mount it into the container. As you have `/hostfs` already, you could also update settings to use `/hostfs /var/run/docker.sock`.

Please have in mind permissions too, Metricbeat runs as metricbeat user in the container, so you may need to change that to root, or update permissions on the socket in your host

---

<div class="post-metadata">

**Author:** ![rehan](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@rehan](https://discuss.elastic.co/u/rehan)\
**Post date:** [December 14, 2017, 10:30am UTC](https://discuss.elastic.co/t/issue-with-metricbeat-docker-container/109525/3 "2017-12-14T10:30:20Z")

</div>

Hi,

I made it worked.

But metricbeat is not giving correct information of docker.

Regards

Raihan

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [December 14, 2017, 10:49am UTC](https://discuss.elastic.co/t/issue-with-metricbeat-docker-container/109525/4 "2017-12-14T10:49:22Z")

</div>

Could you please explain what's wrong about it?

---

<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:** [January 11, 2018, 10:49am UTC](https://discuss.elastic.co/t/issue-with-metricbeat-docker-container/109525/5 "2018-01-11T10:49:39Z")

</div>

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