Docker Swarm on VMware vSphere for Practical Lab Testing

Running Docker Swarm inside VMware vSphere is a useful way to explore container orchestration without committing production hardware or cloud spend. A small virtual lab can demonstrate manager quorum, worker scheduling, overlay networking, rolling updates, service scaling and node failure recovery.

This guide uses a practical layout for IT professionals and home-lab operators: three manager nodes and two worker nodes running Linux virtual machines. The design suits a vSphere cluster, nested lab or workstation-based environment, while leaving enough flexibility to test different storage, networking and automation choices.

Planning The vSphere Lab

Create five virtual machines with consistent names such as swarm-mgr01, swarm-mgr02, swarm-mgr03, swarm-worker01 and swarm-worker02. Ubuntu Server is a convenient guest operating system, although another Docker-supported Linux distribution works well. Allocate 2 vCPUs and 2–4 GB of memory per VM for basic testing, increasing the worker resources when running larger application stacks.

Use static addresses or DHCP reservations. Docker Swarm depends on reliable node-to-node communication, so name resolution should work in both directions. A simple lab network might use a dedicated port group such as 192.168.50.0/24, with outbound access for package downloads. If you want to build the machines repeatedly, PowerCLI automation guide provides a useful starting point for provisioning virtual infrastructure.

Australian home labs frequently operate over NBN connections, where upload capacity can be more restrictive than download speed. Keep container images cached locally where possible, and avoid making the lab dependent on pulling large images during every test. If your environment is in Sydney or Melbourne, using local DNS and nearby registries can also reduce unnecessary latency.

Building The Virtual Machines

Install Docker Engine on every node using the vendor’s supported repository rather than an old distribution package. Confirm that each host reports a unique hostname, correct time, and a reachable IP address. Chrony or systemd-timesyncd should keep clocks aligned, as inconsistent time makes troubleshooting certificates, logs and monitoring data unnecessarily difficult.

The important Swarm ports are TCP 2377 for cluster management, TCP and UDP 7946 for node communication, and UDP 4789 for the VXLAN overlay network. Permit these ports between all five nodes through the guest firewall and any relevant distributed firewall rules. You can keep SSH access restricted to your management subnet.

On vSphere, install VMware Tools or the open-vm-tools package, enable graceful guest shutdown, and check that the virtual NICs use a predictable adapter type. Avoid treating VM snapshots as a backup strategy for active Swarm managers. Snapshots can be useful before a disposable experiment, but restoring several managers to different points in time can create confusing cluster state.

Initialising The Swarm

On the first manager, initialise the cluster with its stable management address:

docker swarm init --advertise-addr 192.168.50.11

Docker prints separate join commands for managers and workers. Run the worker command on both worker VMs, then use the manager join command on the second and third managers. Check the result with:

docker node ls

The three-manager design preserves quorum when one manager fails. It also allows you to practise manager promotion, demotion and maintenance workflows without risking a single-node control plane. Keep an eye on resource allocation: a small home lab may need to power off unrelated VMs while simulating node outages.

Automation becomes valuable once the manual process works. Ansible can install Docker, configure firewall rules and join nodes consistently; these Ansible management tips are relevant when extending the lab across multiple hosts. Store join tokens securely and rotate them after testing if they have been exposed in scripts or terminal history.

Deploying And Testing Services

Deploy a simple web service to confirm scheduling and overlay networking:

docker service create \
  --name web \
  --publish published=8080,target=80 \
  --replicas 3 \
  nginx:alpine

Inspect placement and status with docker service ps web, then test the published address from another machine. Increase the replica count, update the image, and observe how Swarm performs a rolling replacement. Add placement constraints or node labels when you need to keep certain workloads on specific workers.

For a more realistic exercise, deploy a stack file containing a web tier, environment variables, resource limits and an overlay network. Test what happens when a worker is powered off in vSphere, when a service replica is stopped, and when a manager is temporarily unavailable. Record recovery times and confirm that the service remains reachable through the routing mesh.

Use these two compact checklists during a lab session.

Functional checks

Failure checks

Reviewing Results And Cleaning Up

Compare Swarm with other approaches according to the purpose of the lab. Swarm is quick to learn and built into Docker, while Kubernetes offers a broader ecosystem with greater operational complexity. A single Docker host is simpler still, but it cannot demonstrate distributed scheduling or manager quorum.

Approach Best use in a vSphere lab Operational effort Main limitation
Single Docker VM Container basics and image testing Low No cluster resilience
Docker Swarm Lightweight orchestration and failure testing Low to medium Smaller ecosystem than Kubernetes
Kubernetes Enterprise orchestration practice High More components and administration
VM-based application stack Traditional infrastructure testing Medium No container scheduling model

Before deleting the lab, remove services and leave the cluster in a documented state. Capture docker node ls, service definitions, network settings and test results. For Australian businesses, keep production-like data out of an informal home lab and consider obligations under the Privacy Act 1988 when handling personal information. Australian organisations may also need to account for data-location and supplier requirements when images, logs or backups leave the country.

Review the site disclaimer before treating lab results as production guidance. Then convert the successful steps into version-controlled Compose files, Ansible playbooks and repeatable vSphere provisioning code. Build the environment again from scratch, introduce controlled failures, and use the measurements to guide your next infrastructure design.