Skip to content

Instantly share code, notes, and snippets.

@haochunchang
Created February 22, 2019 09:35
Show Gist options
  • Save haochunchang/3bd743ff55afbdac8fc8574373085a7d to your computer and use it in GitHub Desktop.
Save haochunchang/3bd743ff55afbdac8fc8574373085a7d to your computer and use it in GitHub Desktop.
Display GUI applications running in docker (tested in MacOS)
#!/bin/bash
# Display GUI applications running in docker (tested in MacOS)
LOCAL_DIR=$1
DOCKER_DIR=$2
DOCKER_IMAGE=$3
IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}') && echo $IP
xhost + $IP
docker run -it --name display -e DISPLAY=$IP:0 -v /tmp/.X11-unix:/tmp/.X11-unix -v $LOCAL_DIR:$DOCKER_DIR $DOCKER_IMAGE bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment