Created
October 9, 2019 15:53
-
-
Save pedroarthur/59043a11c3359d405667a0508bba8768 to your computer and use it in GitHub Desktop.
Bash script to run a X application in Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USER_ID=$(id -u "$(whoami)") | |
GROUP_ID=$(id -g "$(whoami)") | |
XSOCK=/tmp/.X11-unix | |
XAUTH=$(mktemp /tmp/docker.xauth.XXXX) | |
trap 'rm $XAUTH; ' EXIT | |
xauth nlist "$DISPLAY" \ | |
| sed -e 's/^..../ffff/' \ | |
| xauth -f "$XAUTH" nmerge - | |
docker run \ | |
--env QT_X11_NO_MITSHM=1 \ | |
--env DISPLAY="unix${DISPLAY}" \ | |
--env XAUTHORITY="${XAUTH}" \ | |
--user "${USER_ID}:${GROUP_ID}" \ | |
--volume "$XSOCK:$XSOCK:rw" \ | |
--volume "$XAUTH:$XAUTH:rw" \ | |
"${@}" \ | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment