artgrohe
artgrohe

Reputation: 3382

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.

I installed Docker for Windows (Windows 10 pro, using linux containers) and also Docker for mac.

Then I started both of them and also configured my router to allow the ports they need for TCP and UDP:

Also I deactivated the firewall both on my pc and on my mac.

Then I ran docker swarm init on my macbook, which gave me a join token.

On my windows PC I entered that join command in the console and....... it failed!

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? I would LOVE to test it and use it for local development and testing of my apps. thanks!

Docker Info from Mac

    $ 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

    $ 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 --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"

Upvotes: 3

Views: 2252

Answers (1)

Miq
Miq

Reputation: 4279

The problem is that netiher docker Desktop for Mac nor for Windows with Linux containers are "true" dockers. Both are using virtual machines with Linux os where true docker engine works. 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.

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." Connecting Mac and Windows on Linux containers might not be easy.

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.

Upvotes: 3

Related Questions