WSL2的Ubuntu中安装Docker
注:随着docker的升级,此方法已不可用。
1、配置WSL2和安装Ubuntu,过程略
2、Ubuntu中安装依赖库
sudo apt update&&sudo apt upgrade -y sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
3、配置Docker的GPG公钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4、添加amd64的Docker的清华软件仓库源
sudo add-apt-repository \ "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \ $(lsb_release -cs) stable"
5、安装Docker
sudo apt update sudo apt install docker-ce
6、配置国内镜像加速及日志
vi /etc/docker/daemon.json
{ "registry-mirrors": [ "https://registry.docker-cn.com", "http://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn" ], "log-driver":"json-file", "log-opts": {"max-size":"500m", "max-file":"3"} }
7、搜索镜像和创建容器
sudo service docker start sudo docker search hello-world sudo docker run hello-world