目的:我们是要得到一个linux的server。
步骤如下:
首先要开启虚拟技术
下载docker ,Install Docker Desktop on Windows | Docker Documentation
下载好后安装
安装完成需要重启windows去开启hyper-v
如果你想去访问官网,你可以去Docker Hub create一个account
查看docker是否成功
点击Hyper-V Manager
你可以看到MobyLinuxVM正在运行
点击上图右边 hyper-v设定,可以更换虚拟机和虚拟机硬盘位置设定。不需要的可以不用设置。
更改配置后需要重启
可以自定义docker 资源配置
也可以共享driver,看自己需要
如果是公司内部内网,需要设置代理
到此就ok了。
如果你想要windows server。
可以docker info去看docker信息
需要改变默认docker地址(默认image地址应该是C:\ProgramData\Docker\windowsfilter,改变地址后image存放的目录应该会是设定目录下的windowsfilter这个目录,我这个没实操过)的可以点击basic,让它变advance
修改下面就好,但这个目录必须先存在。
之后重启docker。
How to SSH into the Docker VM (MobyLinuxVM)
How to SSH into the Docker VM (MobyLinuxVM) on Windows | Jon Gallant
该做法应该是说先run一个ubuntu 的container,通过这个container去访问MobyLinuxVM
•get a privileged container with access to Docker daemon
docker run --privileged -it -v /var/run/docker.sock:/var/run/docker.sock jongallant/ubuntu-docker-client
•run a container with full root access to MobyLinuxVM and no seccomp profile (so you can mount stuff)
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
•switch to host FS
chroot /host