Ubuntu 20.04 wls2
cd ~ vim ./bashrc
#复制到./bashrc hostname="wslhost" wslip=$(ip address show eth0 | grep 'inet ' | awk '{print $2}' | awk -F/ '{print $1}') cp /mnt/c/Windows/System32/drivers/etc/hosts /tmp sed -i "/$hostname/d" /tmp/hosts echo "$wslip $hostname" >> /tmp/hosts cp /tmp/hosts /mnt/c/Windows/System32/drivers/etc/hosts
source ~/.bashrc # 使更新,立即生效
会修改Windows hosts文件(位置:C:\Windows\System32\drivers\etc\hosts),效果如下:
1.配置xshell shh登录
ssh://wslhost:22
2.配置docker
2.查看docker容器和镜像