Skip to content

How to provide Wayland socket to docker container

mviereck edited this page Oct 6, 2018 · 1 revision

How to provide Wayland socket to docker container

To run Wayland applications in docker, you need an already running Wayland compositor like Gnome-Wayland or Weston.

  • Wayland compositors normally provide an X display with Xwayland, too. You can share access to Xwayland the same way as access to regular Xorg.
  • You have to share the Wayland socket. You find it in XDG_RUNTIME_DIR and its name is stored in environment variable WAYLAND_DISPLAY.
  • XDG_RUNTIME_DIR only allows access for its owner, so you need the same user in container as on host.
  • Example similar to x11docker option --hostwayland:
docker run -e XDG_RUNTIME_DIR=/tmp \
           -e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
           -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY  \
           --user=$(id -u):$(id -g) \
           imagename waylandapplication
  • QT5 applications also need -e QT_QPA_PLATFORM=wayland and must be started with imagename dbus-launch waylandapplication.
  • You can combine Wayland access and X access to provide both to docker container.
    • You can indicate that you prefer Wayland with -e XDG_SESSION_TYPE=wayland
  • Collection of Wayland related environment variables for different toolkits:
    • GTK: GDK_BACKEND=wayland
    • QT5: QT_QPA_PLATFORM=wayland
    • Clutter/GTK3: CLUTTER_BACKEND=wayland
    • SDL: SDL_VIDEODRIVER=wayland
    • E / Enlightenment: ELM_DISPLAY=wl ELM_ACCEL=opengl ECORE_EVAS_ENGINE=wayland_egl
Clone this wiki locally