记录如何在wsl2上启用docker服务。
安装过程
- 安装依赖
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
- 信任 Docker 的 GPG 公钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- 添加软件仓库
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
- 最后安装
sudo apt-get update
sudo apt-get install docker-ce
配置环境
- 添加用户
sudo adduser $USER docker
- 重启服务
sudo service docker restart
- 尝试运行
docker run hello-world
docker images
如果报错,可能是被墙了,建议f墙后再次尝试。
Enjoy it !