Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- echo "== Start WSL2 Docker with domains wsl2 and winhost in host file =="
- echo "Try to set ip for windows and WSL hosts"
- export WIN_HOST_IP=$(cat /etc/resolv.conf | grep 'nameserver' | cut -f 2 -d ' ')
- export WSL_HOST_IP=$(ip addr show eth0 | grep 'inet ' | cut -f 6 -d ' ' | cut -f 1 -d '/')
- echo "Found windows host ip: $WIN_HOST_IP"
- echo "Found WSL2 host ip: $WSL_HOST_IP"
- rm /tmp/hosts
- if grep "wsl2" /mnt/c/Windows/System32/drivers/etc/hosts
- then
- cp /mnt/c/Windows/System32/drivers/etc/hosts /tmp/hosts
- sed -i "s/.*wsl2/$WSL_HOST_IP wsl2/" /tmp/hosts
- cat /tmp/hosts > /mnt/c/Windows/System32/drivers/etc/hosts
- else
- echo "$WSL_HOST_IP wsl2\n" >> /mnt/c/Windows/System32/drivers/etc/hosts
- fi
- rm /tmp/hosts
- if grep "winhost" /mnt/c/Windows/System32/drivers/etc/hosts
- then
- cp /mnt/c/Windows/System32/drivers/etc/hosts /tmp/hosts
- sed -i "s/.*winhost/$WIN_HOST_IP winhost/" /tmp/hosts
- cat /tmp/hosts > /mnt/c/Windows/System32/drivers/etc/hosts
- else
- echo "$WIN_HOST_IP winhost\n" >> /mnt/c/Windows/System32/drivers/etc/hosts
- fi
- #cat /mnt/c/Windows/System32/drivers/etc/hosts
- echo "done.\n"
- echo "Start Docker."
- sudo nohup dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --dns 8.8.8.8 >/dev/null 2>&1 &
- echo "done.\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement