[window10+docker+wsl2] ubuntu20.04 no network
[window10+docker+wsl2] ubuntu20.04 no network

[window10+docker+wsl2] ubuntu20.04 no network

問題描述

開發環境整合window10+docker+wsl2+ubuntu20.04時,如果發生網路無法連線。

例如:apt update,docker build .....等等。
錯誤訊息:
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Temporary failure resolving 'security.ubuntu.com'

解決方法如下:

For ubuntu20.04
sudo nano /etc/resolv.conf

# 修改前
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.28.16.1

# 修改後
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 8.8.8.8