[英]How to connect two local machines via docker swarm?
I would like to test some docker swarm features and for that I have a windows PC and a mac book pro, both in my private Network.我想测试一些 docker swarm 功能,为此我在我的私人网络中有一台 Windows PC 和一台 mac book pro。
I installed Docker for Windows (Windows 10 pro, using linux containers) and also Docker for mac.我安装了 Docker for Windows(Windows 10 pro,使用 linux 容器)和 Docker for mac。
Then I started both of them and also configured my router to allow the ports they need for TCP and UDP:然后我启动了它们,并配置了我的路由器以允许 TCP 和 UDP 所需的端口:
Also I deactivated the firewall both on my pc and on my mac.此外,我在我的 PC 和 Mac 上都停用了防火墙。
Then I ran docker swarm init on my macbook, which gave me a join token.然后我在我的 macbook 上运行 docker swarm init,它给了我一个加入令牌。
On my windows PC I entered that join command in the console and....... it failed!在我的 Windows PC 上,我在控制台中输入了该 join 命令,然后......它失败了!
I got an error message that ends with "... connection refused".我收到一条以“...连接被拒绝”结尾的错误消息。
So, can you give me some advise or links to how to properly connect to local machines via docker swarm?那么,你能给我一些关于如何通过 docker swarm 正确连接到本地机器的建议或链接吗? I would LOVE to test it and use it for local development and testing of my apps.我很想测试它并将其用于我的应用程序的本地开发和测试。 thanks!谢谢!
Docker Info from Mac来自 Mac 的 Docker 信息
$ docker info
Containers: 2
Running: 2
Paused: 0
Stopped: 0
Images: 185
Server Version: 18.03.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
NodeID: v3fhiinezmdbbn98l0s6bgqzo
Is Manager: true
ClusterID: o9mcdlgtq37t5r86ganupstez
Managers: 1
Nodes: 1
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 192.168.65.3
Manager Addresses:
192.168.65.3:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.87-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 4.095GiB
Name: linuxkit-025000000001
ID: 2D57:Q3QP:6UZ2:S6JV:WXLG:JN4H:TR6G:V3C3:P6ZP:2ENA:L7ES:OIJD
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
HTTP Proxy: docker.for.mac.http.internal:3128
HTTPS Proxy: docker.for.mac.http.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Docker Info from Windows来自 Windows 的 Docker 信息
$ docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 18.09.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce
runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 3
Total Memory: 7.768GiB
Name: linuxkit-00155d674805
ID: S7LD:PA6I:QGZR:YFQH:BR62:JS5C:DZLS:C6O3:RZUL:7ZXE:PRI6:HPRD
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 22
Goroutines: 46
System Time: 2019-04-11T13:28:11.3484452Z
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
Docker swarm join command output Docker swarm join 命令输出
$ docker swarm join --token SWMTKN-1-5rp7ownwv3ob27vl52ogo8z6d3mbxasdfasdfsadfkrf8hqjk1b5-bi2p5u7i7blk5wepw389sba0w 192.168.x.x:2377
Error response from daemon: rpc error: code = Unavailable desc = all
SubConns are in TransientFailure, latest connection error:
connection error:
desc = "transport: Error while dialing dial tcp 192.168.x.x:2377:
connect: connection refused"
The problem is that netiher docker Desktop for Mac nor for Windows with Linux containers are "true" dockers.问题在于,无论是 Mac 的 docker Desktop 还是带有 Linux 容器的 Windows 都是“真正的”docker。 Both are using virtual machines with Linux os where true docker engine works.两者都使用带有 Linux 操作系统的虚拟机,其中真正的 docker 引擎可以工作。 If I'm correct, 192.162.65.3 is not the IP of your Mac but the IP of vm within some virtual mac network.如果我是对的,192.162.65.3 不是您 Mac 的 IP,而是某个虚拟 mac 网络中 vm 的 IP。
Basing on this article https://docs.docker.com/docker-for-mac/docker-toolbox/ and this sentence "Also note that Docker Desktop for Mac can't route traffic to containers, so you can't directly access an exposed port on a running container from the hosting machine."基于这篇文章https://docs.docker.com/docker-for-mac/docker-toolbox/和这句话“另请注意,Docker Desktop for Mac 无法将流量路由到容器,因此您无法直接访问来自托管机器的正在运行的容器上的暴露端口。” Connecting Mac and Windows on Linux containers might not be easy.在 Linux 容器上连接 Mac 和 Windows 可能并不容易。
I'd recommend for testing either get some cloud VMs or on Windows you can use docker-machine command to spawn multiple Linux VMs on which you can setup local swarm to test features you wish.我建议测试获取一些云虚拟机或在 Windows 上,您可以使用 docker-machine 命令生成多个 Linux 虚拟机,您可以在这些虚拟机上设置本地 swarm 以测试您希望的功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.