Trying to run Firefox on Pi with exec node and SSH - Error: no DISPLAY environment variable specified

I'm sure this is very simple for those who knows how it's done, but I don't... I have a command line that is supposed to start Firefox to NRK streaming, the Norwegian counterpart to BBC, with an SSH message from the Docker container Node-RED runs in on the same Pi. This is the command I use:

sshpass -p SECRET_PASSWORD ssh pi@192.168.10.103 -o StrictHostKeyChecking=no /usr/bin/firefox --private-window https://tv.nrk.no/serie/mesternes-mester/sesong/17/episode/KMTE60000726

The page probably doesn't work outside of Norway for copyright reasons. But this gives me the error in the topic, Error: no DISPLAY environment variable specified

I think I understand why, it's because the command isn't sent to the GUI session that I have open on the Pi. But how should I do this to make it work?

You should be able to add the environment variable setting before the command. If you do an internet search, you should easily find the exact text - been a very long time since I did it so I can't quite remember the code.

This happens because, when you run Node-RED from systemd, it does not get (and indeed, should not get) the standard user environment variables.

Thanks for answering! Especially when it's ran from a Docker container, as I do, which is it's own environment in itself. I tried to searh for environment variable, but the answers only confused me more, I'm afraid... I am running as the standard user pi, if that helps any.

Ah, you probably should have led with that. :wink: I've updated the tags on this thread accordingly.

Not really :smiley:.

I'm not much good with Docker - but I'm fairly good at internet searches. :man_mage: So try this:

Actually I did lead with that, in the first message. :grinning_face: But if I understand what you have found correctly it is not the same. I do not want to expose the desktop to the container, I only want to be able to send the command with SSH to the host.

My bad.

You've not chosen an easy approach and I'd question whether you are getting any benefit at all from using Docker for Node-RED? But if you really have to do it that way, first you will have to have a method for safely accessing the host from the container - I have to assume that you've done that?

Then the command you run on the host has to be prefixed with setting the display environment variable.