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.

Revisions

  1. haochunchang created this gist Feb 22, 2019.
    9 changes: 9 additions & 0 deletions display_in_docker.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/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