Skip to content

Commit

Permalink
--hostnet: fix host IP, e.g. for --pulseaudio=tcp #266
Browse files Browse the repository at this point in the history
  • Loading branch information
mviereck committed Jul 24, 2020
1 parent a34c2c3 commit 9b6a390
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions x11docker
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ waitforlogentry() { # wait for entry $3 in logfile $2 of application
local Startzeit Uhrzeit Dauer Count=0 Schlaf
local Errorkeys="${4:-}"
local Warten="${5:-60}"
local Error
local Error=

Startzeit="$(date +%s ||:)"
Startzeit="${Startzeit:-0}"
Expand Down Expand Up @@ -4105,9 +4105,9 @@ create_dockercommand() { ### create command to run docker
# --share
while read -r Line; do
case "$Line" in
"$Containeruserhome")
"$Containeruserhosthome")
Dockercommand="$Dockercommand \\
--volume $(convertpath volume "$Containeruserhome" "/home.host/$Containeruserhome")"
--volume $(convertpath volume "$Containeruserhosthome" "/home.host/$Containeruser")"
;;
*)
case "$(cut -c1-5 <<< "$Line")" in
Expand Down Expand Up @@ -5691,7 +5691,7 @@ create_dockerrc() { ### create dockerrc: This script runs as root (o
case "$Line" in
"$Containeruserhosthome")
echo " echo '# --share: create soft link of shared file/folder/volume $(basename "$Line") to container home'"
echo " echo 'ln -s \"/home.host\$Containeruserhome\" \"\$Containeruserhome\"'"
echo " echo 'ln -s \"/home.host/\$Containeruser\" \"\$Containeruserhome/home.host.$Containeruser\"'"
echo " echo ''"
;;
*)
Expand Down Expand Up @@ -6102,6 +6102,11 @@ start_hostexe() { # options --exe, --xonly: Run host executeable i
echo "unset $Waylandtoolkitvars"
}
echo ""
case $Xserver in
--weston|--kwin|--hostwayland)
echo "unset DISPLAY XAUTHORITY"
;;
esac

echo "export HOME='$Containeruserhome'"
echo "cd '$Containeruserhome'"
Expand Down Expand Up @@ -6289,10 +6294,15 @@ check_host() { # check host environment
# Check host IP. Needed for --pulseaudio=tcp, --printer=tcp, --xoverip and --xwin
case $Winsubsystem in
"")
Hostip="$(ip -4 -o a | grep 'docker0' | awk '{print $4}' | cut -d/ -f1 | grep 172.17.0.1)"
#[ "$Hostip" ] || Hostip="$($Dockerexe network inspect bridge --format='{{.IPAM.Config}}' 2>/dev/null | awk '{print $2}')"
[ "$Hostip" ] || Hostip="$(ip -4 -o a | grep 'docker0' | awk '{print $4}' | cut -d/ -f1 | head -n1)"
[ "$Hostip" ] || Hostip="$(ip -4 -o a | awk '{print $4}' | cut -d/ -f1 | grep -v 127.0.0.1 | head -n1)"
case $Sharehostnet in
yes) Hostip="127.0.0.1" ;;
no)
Hostip="$(ip -4 -o a | grep 'docker0' | awk '{print $4}' | cut -d/ -f1 | grep 172.17.0.1)"
#[ "$Hostip" ] || Hostip="$($Dockerexe network inspect bridge --format='{{.IPAM.Config}}' 2>/dev/null | awk '{print $2}')"
[ "$Hostip" ] || Hostip="$(ip -4 -o a | grep 'docker0' | awk '{print $4}' | cut -d/ -f1 | head -n1)"
[ "$Hostip" ] || Hostip="$(ip -4 -o a | awk '{print $4}' | cut -d/ -f1 | grep -v 127.0.0.1 | head -n1)"
;;
esac
;;
*)
Hostip="$(ipconfig.exe | rmcr | grep -A6 'DockerNAT' | grep 'IPv4' | rev | cut -d' ' -f1 | rev)"
Expand Down

0 comments on commit 9b6a390

Please sign in to comment.