|
|
@ -2,13 +2,13 @@ |
|
|
|
#https://blog.yadutaf.fr/2017/09/10/running-a-graphical-app-in-a-docker-container-on-a-remote-server/ |
|
|
|
|
|
|
|
# Prepare target env |
|
|
|
CONTAINER_DISPLAY="0" |
|
|
|
CONTAINER_HOSTNAME="test" |
|
|
|
CONTAINER_HOME="test" |
|
|
|
HOST_DOCKER_IP=172.17.0.1 |
|
|
|
|
|
|
|
# Create a directory for the socket |
|
|
|
mkdir -p display/socket |
|
|
|
touch display/Xauthority |
|
|
|
#mkdir -p display/socket |
|
|
|
|
|
|
|
echo "" > Xauthority |
|
|
|
|
|
|
|
# Get the DISPLAY slot |
|
|
|
DISPLAY_NUMBER=$(echo $DISPLAY | cut -d. -f1 | cut -d: -f2) |
|
|
@ -17,15 +17,10 @@ DISPLAY_NUMBER=$(echo $DISPLAY | cut -d. -f1 | cut -d: -f2) |
|
|
|
AUTH_COOKIE=$(xauth list ${DISPLAY} | awk '{print $3}') |
|
|
|
|
|
|
|
# Create the new X Authority file |
|
|
|
xauth -f display/Xauthority add 172.17.0.1:${DISPLAY_NUMBER} MIT-MAGIC-COOKIE-1 ${AUTH_COOKIE} |
|
|
|
|
|
|
|
# Proxy with the :0 DISPLAY |
|
|
|
#socat TCP4:localhost:60${DISPLAY_NUMBER} UNIX-LISTEN:display/socket/X${CONTAINER_DISPLAY} & |
|
|
|
xauth -f Xauthority add ${HOST_DOCKER_IP}:${DISPLAY_NUMBER} MIT-MAGIC-COOKIE-1 ${AUTH_COOKIE} |
|
|
|
|
|
|
|
# Launch the container |
|
|
|
docker run -it --rm \ |
|
|
|
-e DISPLAY=172.17.0.1:${DISPLAY_NUMBER} \ |
|
|
|
-v ${PWD}/display/socket:/tmp/.X11-unix \ |
|
|
|
-v ${PWD}/display/Xauthority:/home/${CONTAINER_HOME}/.Xauthority \ |
|
|
|
--hostname ${CONTAINER_HOSTNAME} \ |
|
|
|
-e DISPLAY=${HOST_DOCKER_IP}:${DISPLAY_NUMBER} \ |
|
|
|
-v ${PWD}/Xauthority:/home/${CONTAINER_HOME}/.Xauthority \ |
|
|
|
docker-x-test /bin/bash |
|
|
|