啟用 WSL
確定系統(tǒng)為 Windows 10 2004 以后的版本
右擊“菜單”-“設置”-“應用”-“程序和功能”-“啟用或關(guān)閉Windows功能”
框選“適用于Linux的Windows子系統(tǒng)”
重啟系統(tǒng)應用設置
安裝 WSL2 Ubuntu 20.04
啟用 WSL2
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl --set-default-version 2
打開“Microsoft Store”,搜索 Ubuntu20.04,并點擊安裝
下載完成之后,從開始菜單啟動 Ubuntu 20.04 LTS
更新軟件源并更新
sudo tee /etc/apt/sources.list << EOF
deb http://mirrors.163.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ $(lsb_release -cs)-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ $(lsb_release -cs)-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ $(lsb_release -cs)-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ $(lsb_release -cs)-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed $(lsb_release -cs) restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports $(lsb_release -cs) restricted universe multiverse
EOF
sudo apt-get update
sudo apt-get upgrade -y
安裝 docker
sudo apt-get install -y apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu bionic stable"
# 目前 20.04 還沒有國內(nèi)清華 docker 源,暫時用 18.04 版本
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo cp /mnt/c/Windows/Fonts /usr/share/fonts/chinese -r
cd /usr/share/fonts/chinese
sudo mkfontscale
sudo mkfontdir
fc-cache -fv
source /etc/profile
sudo chmod -R 755 *
安裝 zsh
sudo apt-get install zsh
sh -c "$(wget -O- https://gitee.com/kingscat/ohmyzsh/raw/master/tools/install.sh)"
到此這篇關(guān)于Windows10安裝WSL2 Ubuntu20.04并設置docker環(huán)境的方法的文章就介紹到這了,更多相關(guān)Windows10安裝WSL2 Ubuntu20內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!