Create local Cluster of Docker containers (Windows batch scripts for Windows host)
This set of Windows [cmd] batch scripts and Dockerfiles creates a "cluster" of docker containers (Ubuntu Linux based) on the local machine, which can be controlled from the "admin" container. Cluster can be created using one script: "0_create_cluster.cmd".
When you run the "0_create_cluster.cmd" it does the following:
- Creates new Docker network subnet "clusternet", where all the containers will be connected to. You can chose the IP mask and subnet in variables section of the script.
- Two Docker images are created from Dockerfiles (first the admin then the client) which may take few minutes. If you keep these images afterwards (i.e. not delete them on purpose or edit the Dockerfiles), next time you run this script it will going re-use them again, so the cluster set up will be much faster.
- It then starts the "admin" container first, which has only user "root" and allows paswordless ssh into each of the client containers or use "pdsh" (parallel shell) to execute commands via ssh on all the client containers simultaneously (or only on the ones your specify).
- Then it starts as many single-user "client" containers as many there are lines in the file "userlist.txt", which should contain 2 columns: "username" and "password" separated by the [space]. For each line of the "userlist.txt" a client container is created, with the same [hostname=containername=username] and password from the 2nd column of the list of users.
- Additionally all the users home folders from all client containers are created in local folder "clusterhomes", which is created and mounted as /home to each container on the startup.
- Each client container runs its own TurboVNC server as a user, hooked up to the port 590X of the host, where X is the line number in "userlist.txt".
- E.g. to VNC into 5th container, you should connect to localhost:5 with vncviewer using password from line 5 of the "userlist.txt".
- VNC server can aslo be manually started on admin container's :5901 (/bin/startvnc) and will be mapped to localhost:5999 of the host.
- The whole cluster can be stopped and re-started or paused and resumed, thus preserving existing containers (or destroyed and recreated). /homes can be wiped out on startup [default behaviour] or kept if necessary.
When "0_create_cluster.cmd" completes you should have N+1 container (N clients+admin) running.
You can connect to the admin container as
docker exec -ti admin bash
and running e.g. "pdsh hostname" should make all clients to report back with their hostnames.
All other cmd scripts listed here are just for convenient stopping/pausing/resuming of the "cluster".