# Adapt docker run command dor BalenaOS

**URL:** <https://forums.balena.io/t/adapt-docker-run-command-dor-balenaos/47777>\
**Category:** balenaOS\
**Tags:** docker\
**Created:** [November 28, 2019, 8:04pm UTC](https://forums.balena.io/t/adapt-docker-run-command-dor-balenaos/47777 "2019-11-28T20:04:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpierrat](https://avatars.discourse-cdn.com/v4/letter/l/edb3f5/32.png) [@lpierrat](https://forums.balena.io/u/lpierrat)\
**Post date:** [November 28, 2019, 8:04pm UTC](https://forums.balena.io/t/adapt-docker-run-command-dor-balenaos/47777/1 "2019-11-28T20:04:25Z")

</div>

Hi,

I have a docker container that I run with the following command:

```auto
docker run -d \
  --name=metricbeat \
  --user=root \
  --volume="$(pwd)/metricbeat.docker.yml:/usr/share/metricbeat/metricbeat.yml:ro" \
  --volume="/var/run/docker.sock:/var/run/docker.sock:ro" \
  --volume="/sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro" \
  --volume="/proc:/hostfs/proc:ro" \
  --volume="/:/hostfs:ro" \
  docker.elastic.co/beats/metricbeat:6.8.5 metricbeat

```

From [https://www.elastic.co/guide/en/beats/metricbeat/6.8/running-on-docker.html#\_volume\_mounted\_configuration](https://www.elastic.co/guide/en/beats/metricbeat/6.8/running-on-docker.html#_volume_mounted_configuration)

It works fine on a “classic” linux distribution (like Ubuntu), but how can I achieve the same on BalenaOS ? Especially the volume mount, as BalenaOS doesn’t allow bind mounts.

I had a look at this project:

> **[balena-io-playground/multicontainer-metrics](https://github.com/balena-io-playground/multicontainer-metrics)**
>
> An example of using Telegraf from influxdata.com to log device metrics to a InfluxDB server. - balena-io-playground/multicontainer-metrics

it seems to be the kind of thing I would like to do, but I don’t see any mount in this project.

Could you please help me to make this docker container work on BalenaOS ?

Thanks

---

<div class="post-metadata">

**Author:** ![CameronDiver](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@CameronDiver](https://forums.balena.io/u/CameronDiver)\
**Post date:** [November 28, 2019, 8:13pm UTC](https://forums.balena.io/t/adapt-docker-run-command-dor-balenaos/47777/2 "2019-11-28T20:13:01Z")

</div>

Hey @lpierrat

I believe the `/sys/fs/cgroup` and `/proc` mounts can be achieved with `privileged: true` in the docker-compose.

The docker socket can be achieved with the `io.balena.features.balena-socket` label, described here: [https://www.balena.io/docs/reference/supervisor/docker-compose/#labels](https://www.balena.io/docs/reference/supervisor/docker-compose/#labels)

The host fs cannot be mounted into the container when using balena unfortunately.

For the configuration, the easiest way would be to create a dockerfile which looks similar to:

```auto
FROM docker.elastic.co/beats/metricbeat:6.8.5

COPY metricbeat.docker.yml /usr/share/metricbeat/metricbeat.yml

```

It should work with these changes, let me know how it goes!

---

<div class="post-metadata">

**Author:** ![lpierrat](https://avatars.discourse-cdn.com/v4/letter/l/edb3f5/32.png) [@lpierrat](https://forums.balena.io/u/lpierrat)\
**Post date:** [November 28, 2019, 8:33pm UTC](https://forums.balena.io/t/adapt-docker-run-command-dor-balenaos/47777/4 "2019-11-28T20:33:11Z")

</div>

Thanks for the quick answer!

Indeed, I forgot to mentien that I alreadw have this Dockerfile:

```auto
FROM docker.elastic.co/beats/metricbeat:6.8.5
COPY metricbeat.yml /usr/share/metricbeat/metricbeat.yml
USER root
RUN chown root:metricbeat /usr/share/metricbeat/metricbeat.yml

```

So the docker-compose should be something like this?

```auto
  
version: '2'
services:
  metricbeat:
    build: ./metricbeat
    privileged: true
    labels:
      io.balena.features.balena-socket: '1'

```

Just adding `privileged: true` allow the container to have access to /proc without mounting volumes ?

---

<div class="post-metadata">

**Author:** ![CameronDiver](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@CameronDiver](https://forums.balena.io/u/CameronDiver)\
**Post date:** [November 28, 2019, 8:35pm UTC](https://forums.balena.io/t/adapt-docker-run-command-dor-balenaos/47777/5 "2019-11-28T20:35:33Z")

</div>

Yes I believe the following docker-compose file should behave as expected. Let me know if you have any further questions!

---

<div class="post-metadata">

**Author:** ![lpierrat](https://avatars.discourse-cdn.com/v4/letter/l/edb3f5/32.png) [@lpierrat](https://forums.balena.io/u/lpierrat)\
**Post date:** [November 28, 2019, 8:51pm UTC](https://forums.balena.io/t/adapt-docker-run-command-dor-balenaos/47777/7 "2019-11-28T20:51:11Z")

</div>

Perfect thanks.  
I’ll do some tests tomorrow since I don’t have access to the devices at the moment.
