Node-RED in a docker container doesn't seem to be able to execute some programs with the exec node

I'm running Node-RED in a docker container with a local Linux username "node-red" with a UID/GID=1000 (to match what is in the docker container)

Here is the yaml file that start and runs Node-RED and MariaDB (not used yet)

###############################
# Node-RED Docker Compose file
###############################
version: "3.7"

services:
  node-red:
    image: nodered/node-red:latest
    user: "node-red:node-red"
    restart: unless-stopped
    environment:
      TZ: US/Chicago
    ports:
      - 1880:1880
      - 6880:6880
      - 3991-3993:3991-3993
    volumes:
      - /home/node-red/node-red/data:/data

  db:
    image: mariadb
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: xxxxxxxxx
      MYSQL_DATABASE: NodeRed
      MYSQL_USER: nodered
      MYSQL_PASSWORD: xxxxxxxxx
    volumes:
      - /home/node-red/node-red/maria:/db
    ports:
      - 3306:3306

Here is my flow:

[
    {
        "id": "34abb2a30a38d7f3",
        "type": "debug",
        "z": "db8b975cff44b47b",
        "name": "MQSC",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 470,
        "y": 440,
        "wires": []
    },
    {
        "id": "1316908aa62ba9c6",
        "type": "exec",
        "z": "db8b975cff44b47b",
        "command": "/data/mqm/runmqsc",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "mqsc",
        "x": 270,
        "y": 440,
        "wires": [
            [
                "34abb2a30a38d7f3"
            ],
            [
                "34abb2a30a38d7f3"
            ],
            [
                "34abb2a30a38d7f3"
            ]
        ]
    },
    {
        "id": "e03cf8ebd1386b18",
        "type": "inject",
        "z": "db8b975cff44b47b",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 440,
        "wires": [
            [
                "1316908aa62ba9c6"
            ]
        ]
    }
]

I'm simply trying to execute an MQ program called runmqsc, the goal is to clear queues at 4am. (don't ask, they want me to do it this way)

Before it was in a docker container it all work with full paths to the executables in /opt/mqm/bin. That would not work here so I copied the executables I need to /data/mqm/*
You can see that in the paths below.

What I get in Node-RED is this:

Command failed: /data/mqm/runmqsc
/bin/bash: line 1: /data/mqm/runmqsc: No such file or directory

It finds and runs the script /data/scripts/clear-queue.sh which calls the runmqsc command /data/mqm/runmqsc ... I have tried with this path and ../mqm/runmqsc both give the same error message in Node-RED and the container command line.

And when I go to the docker container command line to validate paths etc. I see this:

[node-red@nodered-s01 mqm]$ docker exec -it red-node-red-1 /bin/bash
bash-5.1$ cd /
bash-5.1$ ls -al
total 88
drwxr-xr-x    1 root     root          4096 May 30 13:52 .
drwxr-xr-x    1 root     root          4096 May 30 13:52 ..
-rwxr-xr-x    1 root     root             0 May 30 13:52 .dockerenv
drwxr-xr-x    1 node-red 188           4096 Aug  4  2022 bin
drwxrwxr-x    9 node-red node-red      4096 May 30 17:42 data
drwxr-xr-x    5 root     root           340 May 30 13:54 dev
drwxr-xr-x    1 node-red 188           4096 May 30 13:52 etc
-rw-r--r--    1 node-red 188            878 Aug  4  2022 healthcheck.js
drwxr-xr-x    1 node-red 188           4096 Aug  4  2022 home
drwxr-xr-x    1 node-red 188           4096 Aug  4  2022 lib
drwxr-xr-x    5 node-red 188           4096 Jul 18  2022 media
drwxr-xr-x    2 node-red 188           4096 Jul 18  2022 mnt
drwxr-xr-x    1 node-red 188           4096 Jul 18  2022 opt
dr-xr-xr-x  232 root     root             0 May 30 13:54 proc
drwx------    1 node-red 188           4096 Jul 18  2022 root
drwxr-xr-x    2 node-red 188           4096 Jul 18  2022 run
drwxr-xr-x    1 node-red 188           4096 Aug  4  2022 sbin
drwxr-xr-x    2 node-red 188           4096 Jul 18  2022 srv
dr-xr-xr-x   13 root     root             0 May 30 13:02 sys
drwxrwxrwt    1 node-red 188           4096 Aug  4  2022 tmp
drwxr-xr-x    1 node-red 188           4096 Aug  4  2022 usr
drwxr-xr-x    1 node-red 188           4096 Aug  4  2022 var
bash-5.1$ cd data
bash-5.1$ ls -al
total 244
drwxrwxr-x    9 node-red node-red      4096 May 30 17:42 .
drwxr-xr-x    1 root     root          4096 May 30 13:52 ..
-rw-r--r--    1 node-red node-red     17380 May 30 13:39 .config.nodes.json
-rw-r--r--    1 node-red node-red     16457 May 30 13:39 .config.nodes.json.backup
-rw-r--r--    1 node-red node-red        95 May 30 13:03 .config.runtime.json
-rw-r--r--    1 node-red node-red       631 May 30 13:40 .config.users.json
-rw-r--r--    1 node-red node-red       544 May 30 13:40 .config.users.json.backup
-rw-r--r--    1 node-red node-red     38563 May 30 17:42 .flows.json.backup
-rw-r--r--    1 node-red node-red       131 May 30 16:00 .flows_cred.json.backup
drwxr-xr-x    4 node-red node-red      4096 May 30 13:39 .npm
-rw-r--r--    1 node-red node-red     40132 May 30 17:42 flows.json
-rw-r--r--    1 node-red node-red       131 May 30 16:00 flows_cred.json
drwxr-xr-x    3 node-red node-red      4096 May 30 13:03 lib
drwxrwxr-x    2 node-red node-red      4096 May 30 17:29 logs
drwxrwxr-x    2 node-red node-red      4096 May 30 17:40 mqm
drwxr-xr-x   49 node-red node-red      4096 May 30 13:39 node_modules
-rw-r--r--    1 node-red node-red     36076 May 30 13:39 package-lock.json
-rw-r--r--    1 node-red node-red       335 May 30 13:39 package.json
drwxrwxr-x    2 node-red node-red      4096 May 30 17:33 scripts
-rw-r--r--    1 node-red node-red     22599 May 30 13:33 settings.js
drwxrwxr-x    2 node-red node-red      4096 May 30 17:05 static
bash-5.1$ cd mqm
bash-5.1$ ls -al
total 1344
drwxrwxr-x    2 node-red node-red      4096 May 30 17:40 .
drwxrwxr-x    9 node-red node-red      4096 May 30 17:42 ..
-r-xr-xr-x    1 node-red node-red    981872 May 30 17:31 dmpmqcfg
-r-xr-xr-x    1 node-red node-red    105608 May 30 17:31 dspmqver
-r-xr-xr-x    1 node-red node-red    261168 May 30 17:31 mqrc
-r-xr-xr-x    1 node-red node-red     15136 May 30 17:31 runmqsc
bash-5.1$ ./runmqsc
bash: ./runmqsc: No such file or directory
bash-5.1$

Am I missing something obvious (because it IS there, and it IS executable, and it IS owned by node-red) or is this something that Node-RED in a docker container is not meant to do?

I wonder whether you an unprintable character or space in the filename
What about
ls ./runmqsc

Also what happens if you type
./ru
And hit tab, and if it completes the name then Enter?

your docker-node-red is indeed running independently from the OS, hence it cannot execute anything that is outside of this container's reach. While you can copy binaries to a persistent folder which docker-node-red has access to, this does not guarantee all dependencies are covered to run the OS binary in your docker-node-red-OS - now or after any update of either OS or container.

There is, however, a solution:

  1. pi is the user I have on my OS. 10.10.1.100 is the ip of my raspberry running everything.
  2. ssh access is via ssh-key, hence you need to generate a key and save it once at the beginning. This can be done by accessing your docker container with docker container exec -it nodered /bin/bash. Then run ssh-keygen -f /data/ssh/id_nr -t rsa -b 4096 and copy your certificate from your docker container to your OS via f.e. ssh-copy-id -i /data/ssh/id_nr iq@10.10.1.100
  3. Finally refer to it, when you access it, like in my example with '-i /data/ssh/id_nr'
1 Like

ok, I figured it out.

I need to at the following two volumes to my docker compose file:

- /opt/mqm:/opt/mqm
- /lib64:/lib64

runmqsc was reporting that it could not fine library files, not that the executable could not be found.

While inside the contained at the command prompt I ran this:

bash-5.1$ ldd runmqsc
        /lib64/ld-linux-x86-64.so.2 (0x7f00f2ab7000)
Error loading shared library libmqmcs_r.so: No such file or directory (needed by runmqsc)
        libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f00f2ab7000)
        libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f00f2ab7000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f00f2ab7000)
        libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f00f2ab7000)
Error relocating runmqsc: xcsDisplayCopyright: symbol not found
Error relocating runmqsc: xehSIGCHLDuseSigAction: symbol not found
Error relocating runmqsc: xcsQueryProcAddr: symbol not found
Error relocating runmqsc: xcsEraseMemoryFn: symbol not found
Error relocating runmqsc: xcsCheckDirectory: symbol not found
Error relocating runmqsc: xtr_FNC_text: symbol not found
Error relocating runmqsc: xcsGetEnv: symbol not found
Error relocating runmqsc: xcsTerminate: symbol not found
Error relocating runmqsc: xcsIsEnvironment: symbol not found
Error relocating runmqsc: xtr_FNC_entry: symbol not found
Error relocating runmqsc: xcsRestoreTerminal: symbol not found
Error relocating runmqsc: xcsRegisterAsySigHandler: symbol not found
Error relocating runmqsc: xcsCheckConsistency: symbol not found
Error relocating runmqsc: xcsQueryValue: symbol not found
Error relocating runmqsc: xcsFileExists: symbol not found
Error relocating runmqsc: xugGetOpt2: symbol not found
Error relocating runmqsc: xcsGetMessage: symbol not found
Error relocating runmqsc: xcsGetPassword: symbol not found
Error relocating runmqsc: xcsInitialize: symbol not found
Error relocating runmqsc: xcsLoadFunction: symbol not found
Error relocating runmqsc: xtr_FNC_retcode: symbol not found
Error relocating runmqsc: xtr_parms: symbol not found
Error relocating runmqsc: xcsProgramInit: symbol not found
Error relocating runmqsc: xcsRedirectProgram: symbol not found
Error relocating runmqsc: xihProcess: symbol not found
Error relocating runmqsc: xihThreadKey: symbol not found

After adding /lib64 as a volume I got this error:

bash-5.1$ ./runmqsc
./runmqsc: error while loading shared libraries: libmqmcs_r.so: cannot open shared object file: No such file or directory

That library is in /opt/mqm/lib ... so now I know that volumes to external libraries and executables are VERY important to have correct in the docker compose file.

1 Like

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