正常在Linux里安装Docker直接参考Docker的安装就可以了。
以下是在Windows10里手动安装Linux的参考及问题解决。
Enable the Windows Subsystem for Linux (WSL)
1. 按照文档手动安装windows 10 子系统,ubuntu 18.04
参考:https://docs.microsoft.com/en-us/windows/wsl/install-on-server
2. 按照文档安装docker ce
https://docs.docker.com/install/linux/docker-ce/ubuntu/
3.如果没有安装windows版本的docker ,直接在windows子系统Linux里安装docker的话会报错
报错:Cannot connect to the Docker daemon. Is the docker daemon running on this host?
解决办法:安装Windows版本的docker https://www.docker.com/products/docker-desktop 并配置开启2375端口,这样才能让ubuntu 里的docker clinet访问Windows下的service.
4. https://www.jianshu.com/p/97d16b68045f
1. 安装Docker in Windows10
- 官网:https://docs.docker.com/docker-for-windows/install/
-
打开Docker Desktop设置:
确保勾选:Expose daemon on localhost:2375 without TLS
2. 在Win10 WSL里安装Ubuntu
-
这教程太多了,自行搜索。大致是打开虚拟化HyperV,安装Windows Feature: WSL,重启,微软商店里安装“Ubuntu18.04”
-
如果无法到商店安装就手动安装:
手动安装windows 10 子系统,ubuntu 18.04
参考:https://docs.microsoft.com/en-us/windows/wsl/install-on-server
- 安装完毕,通过开始菜单 - Ubuntu打开,设置Linux用户名/密码
- Win+R - “Bash”也能打开,注意跟上一步起始目录的区别
- shiift + 右键 ,点击Open Linux shell here
3. Ubuntu18安装Docker CE
- 官网:https://docs.docker.com/install/linux/docker-ce/ubuntu/
- 授于当前用户以root权限运行Docker CLI
# Allow your user to access the Docker CLI without needing root access.
sudo usermod -aG docker $USER
- 安装Docker Compose
# Install Python and PIP.
sudo apt-get install -y python3 python3-pip
# Install Docker Compose into your user's home directory.
pip install --user docker-compose
4. 连接Docker daemon
这个就需要windows下运行docker服务
不通过deamon连接的话,你在Ubuntu里运行docker,就会出现错误:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
- 验证Docker启动成功:
docker info
docker-compose --version
kevinqq@CN:/mnt/c/Users/xxx$ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
至此,已经在WSL Ubuntu里完美配置Docker成功了!
进入ubuntu: shiift + 右键 ,点击Open Linux shell here
命令:docker info
参考文章:https://www.jianshu.com/p/97d16b68045f