Windows開啟Docker遠程連接

Docker是用于創(chuàng)建容器化應用程序的完整開發(fā)平臺。 Docker Desktop是在Windows上開始使用Docker的最佳方法。Windows版Docker桌面部分包含有關Docker桌面社區(qū)穩(wěn)定版的信息。

下載&安裝

開啟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-01
    Enable_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/


希望文中方法對你有用,如果有用,請動動小手點個贊??!

祝生活愉快!

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容