First off: I have read the answers to similar questions on SO, but none of them worked.
The situation:
This works in any scenario.
Install xhost if you don't have it. Then, in bash,
xhost
export DISPLAY=:0.0 xhost +local:docker
After this run your docker run command (or whatever docker command you are running) with -e DISPLAY=$DISPLAY
docker run
-e DISPLAY=$DISPLAY