My experience with Docker Swarm.
powershell should be configured in PATH.
Make sure the below PATH is configured in PATH Environment Variable.
C:\Windows\System32\WindowsPowerShell\v1.0
executing docker-machine should be done in powershell admin mode or else the below error will come.
Below 2 options can be choosed to create Docker Hosts as per your environment
docker-machine create --driver hyperv manager1
docker-machine create --driver virtualbox manager1
Make sure you trigger the above cmd from Powershell or CMD as Administrator or else the below error will come.
Running pre-create checks...
Error with pre-create check: "Hyper-v commands have to be run as an Administrator"
no External vswitch found. A valid vswitch must be available for this command to run.
Find existing network adapters by running the Get-NetAdapter cmdlet.
--> Get-NetAdapter
Create a virtual switch by using the New-VMSwitch cmdlet.
--> New-VMSwitch -name ExternalSwitch -NetAdapterName Ethernet -AllowManagementOS $true
To create an internal switch, run the following command.
--> New-VMSwitch -name InternalSwitch -SwitchType Internal
To create an private switch, run the following command.
--> New-VMSwitch -name PrivateSwitch -SwitchType Private
docker-machine --debug create -d hyperv dockernode1
docker-machine --debug create -d hyperv dockernode2
docker-machine --debug create -d hyperv dockernode3
docker-machine ssh manager1
docker swarm init --advertise-addr
[You can find out the IP by the command: docker-machine ip manager1]
docker-machine ssh dockernode1
docker swarm join --token :2377
[SAME SHOULD BE DONE FOR THE REST WORKER NODEs].
docker-machine --debug create -d hyper manager2 ## create an additional docker manager host.
docker-machine ssh manager2 ## ssh into the newly created manager
docker swarm join-token manager ## execute this command to generate a token from the actual manager.
docker swarm join --token :2377
docker-machine --debug create -d hyper manager3 ## create an additional docker manager host.
docker-machine ssh manager3 ## ssh into the newly created manager
docker swarm join-token manager ## execute this command to generate a token from the actual manager.
docker swarm join --token :2377
docker-machine --debug create -d hyper manager4 ## create an additional docker manager host.
docker-machine ssh manager4 ## ssh into the newly created manager
docker swarm join-token manager ## execute this command to generate a token from the actual manager.
docker swarm join --token :2377
docker-machine --debug create -d hyper manager5 ## create an additional docker manager host.
docker-machine ssh manager5 ## ssh into the newly created manager
docker swarm join-token manager ## execute this command to generate a token from the actual manager.
docker swarm join --token :2377
docker node ls ## this command should be executed from the docker master host.
docker service create --replicas 5 -d -p 9090:80 --name webserver nginx
Confirm the nginx services is running after sometime [you need to wait for sometime for the above service to run].
docker service scale webserver=10