I am trying to run a GUI app inside docker container using X11 forwarding and am not able to get it to work even when binding Xauthority file.
# Dockerfile
FROM alpine
RUN apk --no-cache add xterm
RUN adduser --disabled-password --home /home/user --uid 1000 --gecos 'USER' user
WORKDIR /home/user
USER user
CMD /usr/bin/xterm
I have tried the following commands to run, and none have been successful:
docker run -it --rm -e DISPLAY image
docker run -it --rm -e DISPLAY -v /tmp/.X11-unix image
docker run -it --rm -e DISPLAY -e XAUTHORITY -v $XAUTHORITY image
docker run -it --rm -e DISPLAY -e XAUTHORITY -v $XAUTHORITY -v /tmp/.X11-unix image
docker run -it --rm --net=host --privileged -e DISPLAY -e XAUTHORITY -v $XAUTHORITY -v /tmp/.X11-unix image
Basically, they all produce the same error Can't open display: :0
. At this point, I have run out of all options discussed at StackOverflow and other tutorials
I am not sure if the permissions on the Xauthority file is important, but when I bind, from inside the container, it has root:root
permissions where the host has user:user
permissions.
I have also used (Can you run GUI applications in a Docker container?) but have not had any success with the answers