Tips: How to create and connect a cluster in Docker?
To enable the swarm mode in Docker, we need to create one or more clusters. In this post, we are going to see how to create and connect a cluster.
In Windows 10, Hype-V comes as a default hypervisor. For Hyper-V, we need to create a virtual switch before creating clusters on it and it is pre-requisites.
Do the following steps to create a Virtual Switch in Windows 10
- Open the Hyper-V manager
- Click on Virtual Switch manager on the right-hand side menu
- Select External as type.
- Click on Create Virtual Switch
- Give it the name as myswitch or whatever you want
- Select your host’s primary network adapter (active Ethernet or wireless adapter)
Create a Cluster:
- Open a PowerShell console (terminal in Linux).
- Create a cluster node with the following command:
Windows 10: docker-machine create -d hyperv --hyperv-virtual-switch "myswitch"cluster01 Window 7/Linux: docker-machine create -d virtualbox cluster01
- Check the status of the newly created cluster:
Windows/Linux: docker-machine ls
Connect to a Cluster:
- Open a PowerShell console (terminal in Linux).
- Connect to newly created cluster once it up and running
Windows/Linux: docker-machine ssh cluster01
Now, you are inside a cluster and you can play around with it. Type the following command to list out all directories from the root directory
Linux: ls