aind-containers / aind

AinD: Android in Docker. Ain't an emulator.
Apache License 2.0
1.49k stars 90 forks source link

Make to inherited x11 environment available #68

Closed jc-lab closed 3 years ago

jc-lab commented 3 years ago

It can be used in the X11 environment of the existing desktop.

$ xhost +local:docker # Allows access to X11 Display through unix socket in Docker.
$ docker run --rm -it --name aind --privileged \
    -v /lib/modules:/lib/modules:ro \
    -e DISPLAY=unix$DISPLAY \
        -e INHERIT_DISPLAY=1 \
    -v /tmp/.X11-unix:/tmp/.X11-unix:ro \
        -e SESSION_MANAGER_ARGS="--single-window" \ # It is also available
    aind/aind

Screenshot: Screenshot

Added environment variables

SESSION_MANAGER_ARGS

Can give options to session-manager. For a similar situation like this: https://github.com/anbox/anbox/issues/800#issuecomment-457783805

POST_SESSION_SCRIPT

This can be useful after anbox is running.

INHERIT_DISPLAY

If not set and DISPLAY is set, it is automatically set to 1.

DISPLAY

X11 display name


A more detailed X11 implementation is possible. Below is a simple VNC example.

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: aind
  name: aind
spec:
  replicas: 1
  selector:
    matchLabels:
      app: aind
  template:
    metadata:
      labels:
        app: aind
    spec:
        securityContext:
          privileged: true
...
      containers:
      - name: aind
        image: aind/aind:latest
        tty: true
        securityContext:
          privileged: true
        volumeMounts:
        - name: host-lib-modules
          readOnly: true
          mountPath: /lib/modules
        - name: x11-unix
          readOnly: true
          mountPath: /tmp/.X11-unix
      - name: vnc
        image: vnc-server
        ports:
        - containerPort: 5900
        volumeMounts:
        - name: x11-unix
          mountPath: /tmp/.X11-unix
      volumes:
      - name: x11-unix
        emptyDir: {}
      - name: host-lib-modules
        hostPath:
          path: /lib/modules
AkihiroSuda commented 3 years ago

Thanks!