vcgencmd from a docker container

It took me quite a lot of time to figure this out, but to be able to run the vcgencmd command from a container you just need to add the following options to your docker run command:

--device=/dev/vchiq -e LD_LIBRARY_PATH=/opt/vc/lib -v /opt/vc:/opt/vc:ro

1) docker run example:

$ docker run -d --name my_container --device=/dev/vchiq -e LD_LIBRARY_PATH=/opt/vc/lib -v /opt/vc:/opt/vc:ro influxdb:1.8.9
f7c847bea90edc7d56aed666ac9f6c8264d4cc0f8817862e669aac06d750e977

$ docker exec -it my_container bash
root@f7c847bea90e:/# /opt/vc/bin/vcgencmd measure_temp
temp=42.2'C
root@f7c847bea90e:/# exit
$

2) docker-compose example:

version: "3.5"
  services:
    telegraf:
      image: influxdb:1.8.9
      restart: always
      volumes:
        - /opt/vc:/opt/vc:ro
      devices:
        - "/dev/vchiq:/dev/vchiq"
      environment:
        - LD_LIBRARY_PATH=/opt/vc/lib

That’s it! As easy as that.

Find the post where I found this solution and its original author here: https://github.com/fchauveau/rpi-domoticz-docker#pro-tips

Acerca de dafero

Mi nombre es Daniel Fernández, Graduado en Ingeniería Informática. En el caso de querer ponerse en contacto conmigo podéis hacerlo a través de al dirección: daferoES en Gmail.com o a través de Twitter https://twitter.com/dafero
Esta entrada fue publicada en raspberry y etiquetada , . Guarda el enlace permanente.

Deja una respuesta

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s