# Use vcgencmd within a docker node-red container

**URL:** <https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050>\
**Category:** General\
**Created:** [12 March 2020 20:58 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050 "2020-03-12T20:58:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![DannyBoyKN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyboykn/32/15341_2.png) [@DannyBoyKN](https://discourse.nodered.org/u/DannyBoyKN)\
**Post date:** [12 March 2020 20:58 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/1 "2020-03-12T20:58:36Z")

</div>

I have node-red docker container running on my Pi4B and configured several dashboards successfully. For showing the raspberry temperature usually the `vcgencmd` is used. Directly under the Pi that works out of the box, but in the container the `vcgencmd` cannot be found.

Following the description for [node-red-contrib-vcgencmd](https://flows.nodered.org/node/node-red-contrib-vcgencmd) under 'Usage via Docker' several setups need to be configured in order to use the `vcgencmd`.

I've done all that, but `vcgencmd` can still not be found !?

`/dev/vchiq` exist and I can retrieve information out of it:

```auto
>$ cat /dev/vchiq
...

```

If I attach a shell to the container and change into the `/opt/vc/bin` folder, it shows the `vcgencmd`. But executing it gives an error:

```auto
>$ vcgencmd measure_temp
sh: vcgencmd: not found

```

What does this mean ?  
Does anybody has an idea ?

Many thanks

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 March 2020 21:11 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/2 "2020-03-12T21:11:03Z")

</div>

Try `/opt/vc/bin/vcgencmd`  
If that works then it is just that the folder is not in the path.

---

<div class="post-metadata">

**Author:** ![DannyBoyKN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyboykn/32/15341_2.png) [@DannyBoyKN](https://discourse.nodered.org/u/DannyBoyKN)\
**Post date:** [12 March 2020 21:54 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/3 "2020-03-12T21:54:55Z")

</div>

```auto
bash-5.0# /opt/vc/bin/vcgencmd
bash: /opt/vc/bin/vcgencmd: No such file or directory

```

Adding folder to PATH doesn't change this.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 March 2020 22:17 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/4 "2020-03-12T22:17:52Z")

</div>

What does this give

```auto
cd /opt/vc/bin
ls -l

```

Trim it if necessary to show what it says about vcgencmd  
Then if it shows the command  
`./vcgencmd measure_temp`  
Note the dot slash at the start.

---

<div class="post-metadata">

**Author:** ![DannyBoyKN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyboykn/32/15341_2.png) [@DannyBoyKN](https://discourse.nodered.org/u/DannyBoyKN)\
**Post date:** [13 March 2020 17:20 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/5 "2020-03-13T17:20:20Z")

</div>

```auto
>$ ls -la
...
-rwxr-xr-x 1 root root 75508 Feb 5 16:25 raspiyuv
-rwxr-xr-x 1 root root 74068 Jun 24 2019 tvservice
-rwxr-xr-x 1 root root 257820 Jan 20 14:44 vcdbg
-rwxr-xr-x 1 root root 15192 Aug 19 2019 vcgencmd
-rwxr-xr-x 1 root root 69068 Jun 24 2019 vchiq_test
-rwxr-xr-x 1 root root 7824 Jun 24 2019 vcmailbox
-rwxr-xr-x 1 root root 15160 Jun 24 2019 vcsmem
bash-5.0#

```

```auto
bash-5.0# cd /opt/vc/bin/
bash-5.0# ./vcgencmd measure_temp
bash: ./vcgencmd: No such file or directory

```

That's really disappointing ... 🤨 🤔 😔

---

<div class="post-metadata">

**Author:** ![DannyBoyKN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyboykn/32/15341_2.png) [@DannyBoyKN](https://discourse.nodered.org/u/DannyBoyKN)\
**Post date:** [13 March 2020 17:22 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/6 "2020-03-13T17:22:45Z")

</div>

... and I just noticed the node indicates 'not supported'  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/3/932933d21d2612a46df272a97d829657450ab0c5.png)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [13 March 2020 17:25 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/7 "2020-03-13T17:25:19Z")

</div>

@DannyBoyKN,  
I have added that feature at the time being, as it was requested in this [issue](https://github.com/bartbutenaers/node-red-contrib-vcgencmd/issues/2). Perhaps if @mikeS7 is reading this discussion, he might be able to help you. I don't use this in Docker myself!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 March 2020 17:37 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/8 "2020-03-13T17:37:47Z")

</div>

The error must mean that vcgencmd cannot find a file.

---

<div class="post-metadata">

**Author:** ![mikeS7](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikes7/32/2026_2.png) [@mikeS7](https://discourse.nodered.org/u/mikeS7)\
**Post date:** [13 March 2020 17:50 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/9 "2020-03-13T17:50:56Z")

</div>

Could you please share full docker run command

---

<div class="post-metadata">

**Author:** ![DannyBoyKN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyboykn/32/15341_2.png) [@DannyBoyKN](https://discourse.nodered.org/u/DannyBoyKN)\
**Post date:** [13 March 2020 19:05 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/10 "2020-03-13T19:05:49Z")

</div>

It's a compose file:

```auto
version: '3.6'
services:
  nodered:
    image: ctmagazin/ctnodered:latest
  ports:
    - "1880:1880"
  volumes:
    - ./data/nodered:/data
    - ./data/nodered:/usr/src/node-red/node-red-static/
    - /etc/localtime:/etc/localtime
    - /opt/vc:/opt/vc:ro
  devices:
    - /dev/vchiq:/dev/vchiq
  privileged: true
  cap_add:
    - SYS_ADMIN
    - NET_ADMIN
  restart: always
  network_mode: "host"
  environment:
    - TZ=Europe/Berlin
    - LD_LIBRARY_PATH=/opt/vc/lib

```

---

<div class="post-metadata">

**Author:** ![mikeS7](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikes7/32/2026_2.png) [@mikeS7](https://discourse.nodered.org/u/mikeS7)\
**Post date:** [13 March 2020 19:17 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/11 "2020-03-13T19:17:42Z")

</div>

Checked right now, confirmed it doesn't work. It was in time when Node-RED image was based on debian linux. I solved it by using custom image with following in Dockerfile:

```auto
USER root
RUN apk add --no-cache raspberrypi
USER node-red

```

You don't need to use volume mapping in such case.

PS Later I will create PR or open an issue.

---

<div class="post-metadata">

**Author:** ![DannyBoyKN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyboykn/32/15341_2.png) [@DannyBoyKN](https://discourse.nodered.org/u/DannyBoyKN)\
**Post date:** [13 March 2020 19:35 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/12 "2020-03-13T19:35:23Z")

</div>

There seem to be some objects missing:

```auto
>$ bash-5.0$ ldd /opt/vc/bin/vcgencmd
        /lib/ld-linux-armhf.so.3 (0xb6ee0000)
        libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0xb6eca000)
        libvcos.so => /opt/vc/lib/libvcos.so (0xb6eb1000)
        libpthread.so.0 => /lib/ld-linux-armhf.so.3 (0xb6ee0000)
        libdl.so.2 => /lib/ld-linux-armhf.so.3 (0xb6ee0000)
        librt.so.1 => /lib/ld-linux-armhf.so.3 (0xb6ee0000)
        libc.so.6 => /lib/ld-linux-armhf.so.3 (0xb6ee0000)
Error relocating /opt/vc/lib/libvcos.so: backtrace_symbols: symbol not found
Error relocating /opt/vc/lib/libvcos.so: backtrace: symbol not found
Error relocating /opt/vc/lib/libvcos.so: mtrace: symbol not found

```

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [13 March 2020 20:05 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/13 "2020-03-13T20:05:33Z")

</div>

Perhaps you might want to reconsider the use of docker for node-red on a Pi ?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 March 2020 20:18 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/14 "2020-03-13T20:18:28Z")

</div>

Or run a single bash command on the host outside to mqtt publish the data somewhere you can get it more easily...

```auto
while :; do mosquitto_pub -h localhost -p 1883 -t temperature -m $(vcgencmd measure_temp); sleep 10; done

```

---

<div class="post-metadata">

**Author:** ![DannyBoyKN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyboykn/32/15341_2.png) [@DannyBoyKN](https://discourse.nodered.org/u/DannyBoyKN)\
**Post date:** [14 March 2020 15:11 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/15 "2020-03-14T15:11:43Z")

</div>

> [@mikeS7](#):
>
> Checked right now, confirmed it doesn't work. It was in time when Node-RED image was based on debian linux. I solved it by using custom image with following in Dockerfile:
> 
> ```auto
> USER root
> RUN apk add --no-cache raspberrypi
> USER node-red
> 
> ```
> 
> You don't need to use volume mapping in such case.
> 
> PS Later I will create PR or open an issue.

@mikeS7: What does this mean ?  
Do I have to adapt something ?  
Is there a problem with the base image ?  
Do I have to wait for changes ?

---

<div class="post-metadata">

**Author:** ![mikeS7](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikes7/32/2026_2.png) [@mikeS7](https://discourse.nodered.org/u/mikeS7)\
**Post date:** [14 March 2020 17:29 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/16 "2020-03-14T17:29:24Z")

</div>

@DannyBoyKN  
You have different Linux distributions in a host and in a container.  
You should build your own image, in your case Dockerfile will looks like:

```auto
FROM ctmagazin/ctnodered:latest

RUN apk add --no-cache raspberrypi

```

you should remove - /opt/vc:/opt/vc:ro from compose file

---

<div class="post-metadata">

**Author:** ![DannyBoyKN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyboykn/32/15341_2.png) [@DannyBoyKN](https://discourse.nodered.org/u/DannyBoyKN)\
**Post date:** [14 March 2020 17:54 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/17 "2020-03-14T17:54:19Z")

</div>

Well, yes. The container is based on Alpine 3.11 and the Pi4B is running debian buster ...

However, I removed the volume mapping and rebuild the container from the Dockerfile by adding as you wrote`apk add --no-cache raspberrypi` and restarted the container with no luck ☹

By attaching a bash into the container and did manually:

```auto
>$ su
>$ apk add --no-cache raspberrypi
>$ exit

```

it works 😅... of course it's temporary.

---

<div class="post-metadata">

**Author:** ![mikeS7](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikes7/32/2026_2.png) [@mikeS7](https://discourse.nodered.org/u/mikeS7)\
**Post date:** [15 March 2020 08:38 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/18 "2020-03-15T08:38:38Z")

</div>

@DannyBoyKN  
You can't rebuild container, you should build image and use it in your compose file.

---

<div class="post-metadata">

**Author:** ![DannyBoyKN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyboykn/32/15341_2.png) [@DannyBoyKN](https://discourse.nodered.org/u/DannyBoyKN)\
**Post date:** [22 March 2020 17:10 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/19 "2020-03-22T17:10:24Z")

</div>

Well, acc. the [tutorial](https://docs.docker.com/compose/gettingstarted/) it is rebuilding with `docker-compose up --build -d`, I just tested it.  
I modified my Dockerfile acc. [your suggestion](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/16) and will retry ..  
Many thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 April 2020 17:10 UTC](https://discourse.nodered.org/t/use-vcgencmd-within-a-docker-node-red-container/23050/20 "2020-04-05T17:10:28Z")

</div>

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