Unable to Open Display (Chrome, Pi)

Hi @thgreasi, thanks for the help.

So I have to run some tests because it doesn’t consistently happen. I have seen it occur in all 3 situations though.

  • After downloading a new release (this seems to happen the most)

  • On container restarts

  • Even on a boot, while plugging the unit in (that happened this morning)

It does start and boot correctly probably > 95% of the time though.

We’re building a tv app. The app has two containers;

  • BACKEND - which is a node/react app communicating via websockets.

  • FRONTEND - chromium browser connects to the exposed port.

We are running on the Raspberry Pi 3+. OS images are;

  • BACKEND: - FROM resin/raspberrypi3-node:8

  • FRONTEND - FROM balenalib/raspberrypi3-debian:stretch

The frontend configuration was actually based on a comment from @ aliasbits in this forum, GUI kiosk on prodution resinOS

As it stands. I have;

entrpoint.sh

#!/bin/bash
umount /dev/shm && mount -t tmpfs shm /dev/shm

env > cron_env_file

# start cron
cron

sleep 25
xinit /home/viewer/launchBrowser.sh -- -nocursor

launchBrowser.sh

#!/bin/bash
#Disable DPMS / Screen blanking
xset -dpms
xset s off
xset s noblank

URL=$URL
default='http://localhost:8888/'


while :        # run forever
do
    echo "Launching Browser"
    echo "Browser is ${URL}"
    DISPLAY=:0 sudo chromium-browser --no-sandbox --window-size=7000,7000 --kiosk --start-fullscreen -a --disable-infobars --no-first-run --disable-web-security --user-data-dir --incognito --allow-file-access-from-files --enable-offline-auto-reload-visible-only --disable-gpu --force-device-scale-factor=0.5 ${URL:-$default} viewer
done

Dockerfile:

FROM balenalib/raspberrypi3-debian:stretch


USER root

RUN apt-get update && apt-get install -y --no-install-recommends \
lsb-release \
nano \
chromium-browser \
omxplayer \
scrot \
cron \
sed \
xorg \
xinit \
xinput \
xserver-xorg \
xserver-xorg-legacy \
xserver-xorg-input-evdev \
xserver-xorg-input-libinput \
x11-xserver-utils && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN sed -i "s|allowed_users=console|allowed_users=anybody|" /etc/X11/Xwrapper.config

RUN groupmod -g 19 input # may differ

RUN groupadd viewer && \
echo ‘notsecure\nnotsecure’ | adduser --home /home/viewer --ingroup viewer viewer && \
usermod -aG tty viewer && \
usermod -aG input viewer

COPY entrypoint.sh /home/viewer/entrypoint.sh
COPY launchBrowser.sh /home/viewer/launchBrowser.sh

COPY screenshoter.sh /home/viewer/screenshoter.sh
COPY restartBrowser.sh /home/viewer/restartBrowser.sh
COPY restartAllServices.sh /home/viewer/restartAllServices.sh
COPY cron_env_file /home/viewer/cron_env_file

RUN chmod +x /home/viewer/*
RUN chown viewer:viewer /home/viewer/*

# Add crontab file in the cron directory
ADD crontab /etc/cron.d/hello-cron
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/hello-cron
# Apply cron job
RUN crontab /etc/cron.d/hello-cron

# Allow viewer user to start cron daemon with sudo
RUN echo 'viewer ALL=NOPASSWD: /usr/sbin/cron' >>/etc/sudoers


CMD bash -C "/home/viewer/entrypoint.sh";"bash"