dnephin / dobi

A build automation tool for Docker applications
https://dnephin.github.io/dobi/
Apache License 2.0
309 stars 36 forks source link

Add XSock forwarding for job #162

Open Enteee opened 5 years ago

Enteee commented 5 years ago

Under Linux we can containerize graphical applications by mounting the X socket inside the container. I normally achieve this starting the container with the following script:

#!/usr/bin/env bash
set -ex

IMAGE="${1?Image not given}"

XSOCK=/tmp/.X11-unix
XAUTH=$(mktemp --suffix .xauth)

xauth nlist "${DISPLAY}" | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run -ti \
  --network host \
  --publish-all \
  -e "DISPLAY=$DISPLAY" \
  -e "XAUTHORITY=$XAUTH" \
  -v "$XSOCK:$XSOCK" \
  -v "$XAUTH:$XAUTH" \
  "${IMAGE}"

It would be nice, if dobi could provide an option (X-forward) which does this. Obviously this would be a Linux/X.Org Server only thing.

siredmar commented 4 years ago

You always can create a mount point in dobi that redicts to any files on the host. e.g. the X11 socket or an .Xauthority file.

mount=mount-tmp-x11-unix:
  bind: /tmp/.X11-unix
  path: /tmp/.X11-unix

Using this dobi job to execute qtcreator in a container image:

job=launch-qtcreator:
  use: image-qtcreator-5.12.2
  depends: [image-qtcreator-5.12.2]
  privileged: true
  mounts: 
  - mount-home-dir
  - mount-tmp-x11-unix
  - mount-dev
  interactive: true
  env:
    - "DISPLAY={env.DISPLAY}"
    - "LOCAL_USER_ID={user.uid}"
  annotations:
    description: "-> launch qt creator"