4
4
I'd like to run a containerized GUI application from a remote machine.
I don't want to solve this problem by adding an ssh host to the container because
- I already have access to the host machine over SSH
- It adds unnecessary overhead
- It makes the container non-portable between remote and local use
I can already successfully run GUI apps on the host, but not from within the container. These are the steps I've taken so far:
Host
xauth +
(not for long term, but useful for eliminating possible problems)docker-user
with uid 501000 on host ==docker-user
with uid 1000 in container via namespace feature.Xauthority
file copied todocker-user
home folder
Dockerfile
- Based on alpine
- Installs
xauth
and, for testing purposes,xterm
- Creates
docker-user
with proper uid/gid
docker-compose
- Environment variable
DISPLAY
forwarded in - Volume
/home/docker-user/:/home/docker-user/:ro
to provide.Xauthority
cookie - Volume
/tmp/.X11-unix:/tmp/.X11-unix:ro
to provide X11 socket access - Runs command
su - docker-user -c "export DISPLAY=$DISPLAY && xterm"
su
used to run asdocker-user
DISPLAY
forwarded intosu
context
Unfortunately, this is not yet enough. While xterm on the host OS connects to my local X server without issue, xterm in the container says Xt error: Can't open display: localhost:10.0
.
I've confirmed that "localhost:10.0" is correct, localhost exists in the container's /etc/hosts
, and the cookie and socket are making it through with the right permissions.
What else could possibly be going wrong?
This solution worked for me. Apparently it was enough to just copy .Xauthority file to docker container without need to restart it. – Nikolay Frick – 2018-10-15T20:50:29.427