Created
January 26, 2019 16:58
-
-
Save ouyi/2fe20674eb6c713227dbfa4590b0b220 to your computer and use it in GitHub Desktop.
Run a Docker container with GUI support
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
#!/usr/bin/env bash | |
USAGE="$0 args" | |
if (( $# == 0 )); then | |
echo "$USAGE" | |
exit 1 | |
fi | |
function get_ip() { | |
ifconfig | grep '^en' -A5 | grep inet | grep -v -e inet6 -e 'inet 127' -e '--' | awk '{print $2}' | |
} | |
ip_addr=$(get_ip) | |
if [[ -z "${ip_addr// }" ]]; then | |
echo "No valid ip_addr found" | |
exit 1 | |
fi | |
killall socat | |
socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" & | |
sleep 1 | |
docker run -e DISPLAY=${ip_addr}:0 $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment