Gtk-WARNING **: cannot open display on Raspberry Pi 3 with OpenCV

Hello,

As the title suggests, I’m getting a Gtk-WARNING **: cannot open display: :0 error when trying to run an OpenCV application in a resin/raspberrypi3-python:3.6 Docker.

I checked the camera module using raspistill and it works, but OpenCV wouldn’t. I’ve tried to set the DISPLAY environment value to :0 and :1 but it didn’t help.

Googling tells me that this has something to do with X11Forwarding and/or not being the “pi” user when running the application.

I’m trying to run the test_video.py from https://www.pyimagesearch.com/2015/03/30/accessing-the-raspberry-pi-camera-with-opencv-and-python/