1. 程式人生 > 實用技巧 >win10安裝WSL2並且安裝docker和batter history

win10安裝WSL2並且安裝docker和batter history

1.下載docker Windows desktop,先做這個的原因是會預設開啟WSL2,同時還會提示你安裝對應的kernel

2.微軟商店安裝Ubuntu後,執行

wsl -l -v

看下Ubuntu的名字:

wsl --set-version Ubuntu-18.04 2

再次執行

wsl -l -v

然後執行

$ sudo apt-get remove docker docker-engine docker.io containerd runc
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
$ docker run hello-world
$ docker -- run -p 9999:9999 gcr.io/android-battery-historian/stable:3.1 --port 9999

注意:上面執行docker run hello-world時可能會提示無法connect到docker,此時需要在Ubuntu中再開一個bash,輸入sudo dockerd,再執行

docker run hello-world或者別的image。