Execute fswebcam running Node Red in Docker

I have a problem using the exec node.
Maybe I miss something fundamental. Any Information might help.
The goal was to use a command like this:

fswebcam --rotate 270 /home/pi/nodehttpd/image.jpg

Node Red is started in a Docker container via Docker-Compose.

  nodered:
    container_name: nodered
    build: ./services/nodered/.
    privileged: true
    restart: unless-stopped
    user: "1000"
    ports:
      - 1880:1880
    volumes:
      - ./volumes/nodered/data:/data

"fswebcam" is installed on the host.

I cannot executed it, even with a shell script in the shares /data folder. direct paths etc tested.

Debug : "command not found"

Any suggestions?

Did you try giving the full path to the command ?

Yes,
in the exec node I also tried:

/usr/bin/fswebcam --rotate 270 /home/pi/nodehttpd/image.jpg

I also tried it with a simple bash script in the data folder (getpic.sh), containing the commands above
exec command then was:
bash /data/getpc.sh

the container has it's own isolated file system (that is kind of the point :-). so you would need to either ssh back out of the container to the host - or mount (or maybe alias) the command into the mounted volume (but then it may not have access to all the required libraries (if any are needed))

1 Like

Thank you for help, dceejay.

As workaround I use a node.js script as webserver now.
calling it by http://IPADDRESS:8888/

var http = require("http");
const exec = require("child_process").exec;

function onRequest(request, res) {
  console.log("Request received.");

  var child = exec('bash /home/pi/campic.sh', function(err, stdout, stderr) {
            console.log(stdout);
            console.log(stderr);
            if (err !== null) {
                console.log(`exec error: ${err}`);
            }
  });
}

http.createServer(onRequest).listen(8888, function () {
  console.log("Server has started.");
});

If someone has a better idea, please let me know.

Do you have a better way?

You've opened your own thread so closing this one