Skip to content

Instantly share code, notes, and snippets.

@ouyi
Created January 26, 2019 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ouyi/2fe20674eb6c713227dbfa4590b0b220 to your computer and use it in GitHub Desktop.
Save ouyi/2fe20674eb6c713227dbfa4590b0b220 to your computer and use it in GitHub Desktop.
Run a Docker container with GUI support
#!/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