在 Windows 下,使用 VMware/VirtualBox 需要关闭 Hyper-V,使用 Docker 需要开启 Hyper-V
管理员模式运行 CMD
关闭 Hyper-V
bcdedit /set hypervisorlaunchtype off
开启 Hyper-V
bcdedit /set hypervisorlaunchtype auto
操作后需要重启电脑
若需要 VMware/VirtualBox 与 Docker 共享
(1)关闭 Hyper-V
(2)在 VirtualBox 中的虚拟机中安装 Docker
(3)虚拟机开放 2375 端口
[root@Docker ~]# vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service
Requires=docker-cleanup.timer
[Service]
Type=notify
NotifyAccess=main
EnvironmentFile=-/run/containers/registries.conf
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current \
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
--default-runtime=docker-runc \
--exec-opt native.cgroupdriver=systemd \
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
--init-path=/usr/libexec/docker/docker-init-current \
--seccomp-profile=/etc/docker/seccomp.json \
-H tcp://0.0.0.0:2375 \
-H unix://var/run/docker.sock \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY \
$REGISTRIES
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
KillMode=process
[Install]
WantedBy=multi-user.target
[root@Docker ~]# systemctl daemon-reload
[root@Docker ~]# systemctl restart docker
[root@Docker ~]# ps -ef|grep 2375
root 3313 1 0 11:07 ? 00:00:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2
root 3747 2889 0 11:23 pts/0 00:00:00 grep --color=auto 2375
[root@Docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@Docker ~]# firewall-cmd --zone=public --add-port=2375/tcp --permanent
[root@Docker ~]# firewall-cmd --reload
(4)Windows 设置 DOCKER_HOST 为 tcp://虚拟机 IP:2375/
1@DESKTOP-PG9CCAJ MINGW64 /d/Dev
$ export DOCKER_HOST=tcp://192.168.213.34:2375/
1@DESKTOP-PG9CCAJ MINGW64 /d/Dev
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
参考
https://blog.youkuaiyun.com/sinat_35930259/article/details/79648963 docker的C/S模式及远程访问
https://www.jianshu.com/p/ec98587bf2b6 docker与虚拟机(virtualbox,VMWARE共存)解决方案
https://blog.youkuaiyun.com/xchenhao/article/details/112342219 firewall-cmd 常用操作命令
https://segmentfault.com/a/1190000022020616 开启和禁用hyper-v
https://blog.youkuaiyun.com/lonelymanontheway/article/details/81121446 win 10系统docker for windows 与 vmware关于Hyper-v问题