Docker是用于創(chuàng)建容器化應用程序的完整開發(fā)平臺。 Docker Desktop是在Windows上開始使用Docker的最佳方法。Windows版Docker桌面部分包含有關Docker桌面社區(qū)穩(wěn)定版的信息。
下載&安裝
- 官網(wǎng)下載地址 Docker Desktop for Windows
開啟docker的遠程連接
By default, it will listen on unix:///var/run/docker.sock to allow only local connections by the root user. You could set it to 0.0.0.0:2375 or a specific host IP to give access to everybody, but that is not recommended because then it is trivial for someone to gain root access to the host where the daemon is running.
Similarly, the Docker client can use -H to connect to a custom port. The Docker client will default to connecting to unix:///var/run/docker.sock on Linux, and tcp://127.0.0.1:2376 on Windows.
docker默認的連接方式都是sock連接, 如果需要開啟遠程連接, 則需要指定 0.0.0.0:2375
-
Docker Desktop for Windows的開啟方式如下:
開啟docker客戶端,右擊任務欄的圖標:
Enable_remote_access_to_Docker_for_Windows_10-01Enable_remote_access_to_Docker_for_Windows_10-02?
- 你可能看到General設置最后一項Expose daemon on tcp://localhost:2375 without TLS, 別傻了,我試了,這個不一定生效。

Enable_remote_access_to_Docker_for_Windows_10-03
- 正確的方法是取消Expose daemon ..., 打開設置左側Daemon, 切換右側按鈕從Basic 到Advanced, 編輯下面文本域,增加一條:"hosts": [tcp://0.0.0.0:2375],如下圖:

Enable_remote_access_to_Docker_for_Windows_10-04
到這步docker的遠程連接已經(jīng)開啟了,但是還缺最后一步,要給防火墻添加規(guī)則,開放2375端口。
配置防火墻打開2375端口
- 為了確保能遠程連接上docker deamon, 你需要執(zhí)行以下命令:
netsh advfirewall firewall add rule name="docker_daemon" dir=in action=allow protocol=TCP localport=2375
測試是否成功
- 通過你本機ip 和 2375端口訪問測試是否成功。

Enable_remote_access_to_Docker_for_Windows_10-05
參考文章
https://www.portainer.io/2018/03/enable-remote-access-docker-windows-10/
https://docs.docker.com/docker-for-windows/
希望文中方法對你有用,如果有用,請動動小手點個贊??!
祝生活愉快!

