Skip to content

Custom access to new X server

Kuba Orlik edited this page Feb 12, 2022 · 5 revisions

Custom access to new X server

Running x11docker without an image name (or explicitly with option --xonly) creates an empty X server. In that case, or enforced with option --printenv, x11docker writes some environment variables on stdout. You can use this for custom access to new X server. Example:

#! /bin/bash
read Xenv < <(x11docker --xephyr --printenv)

# run xterm from host on new X server
env $Xenv xterm

# run docker image on new X server
export $Xenv
docker run \
    --env DISPLAY \
    --env XAUTHORITY \
    -v $XAUTHORITY:$XAUTHORITY \
    -v $XSOCKET:$XSOCKET \
    x11docker/xfce

If you like to, you can run two docker images sharing the same X server. Example:

#! /bin/bash
# LXDE desktop in Xephyr
read Xenv < <(x11docker --xephyr --showenv x11docker/lxde)
# Thunar from another image appears on LXDE desktop  
env $Xenv x11docker --hostdisplay x11docker/xfce thunar  
Clone this wiki locally