In this modern era, the world is being transformed at a high rate due to rapid improvements in technology. Moreover, individuals and enterprises are enjoying the benefits such as enhanced operational efficiency, improved security, less labor, and reduced costs as a result of advanced technology. Amongst the latest trends in technology are virtualization and containerization which most developers and computer users are interacting with lately. Virtualization in computing is the act of running multiple operating systems(virtual machines) on the computer hardware of a single physical server. Containerization allows a user to deploy several applications using the same operating system on a single virtual machine or server. This guide will use the VMware workstation(a virtualization software) to run containers and Kubernetes on Windows 10/11.
What are Containers?
Some years back, before containers, when multiple applications were deployed on the same virtual machine, changes in the shared dependencies would affect the rest of the applications. Luckily, containers were developed with the aim of virtualizing the host operating system and isolating an application’s dependencies from other containers on the same machine. Thus, a container is an abstraction technology used to package an application and the files needed to run it and isolates it from the underlying host operating system. With containers, there is no need of using a separate operating system to run each application; hence high utilization of resources at lower costs. Note that containers consist of a container engine and a container image, where the container engine runs applications isolating them from others and the image is the package running the application and its dependencies.
What is Kubernetes?
Containers offer an excellent solution to bundle and run applications. However, you will require a way to manage the containers to ensure there is no downtime. Thus, Kubernetes is the solution with an environment where you can run distributed systems and handle scaling and failover of applications. This open-source container orchestration tool has the role of unifying clusters of machines to form a single pool of resources. In a nutshell, Kubernetes automatically handles container changeover with a restart, replacing, or even killing containers that fail the health check. Hence, Kubernetes(K8s) helps developers and users manage complex applications while conserving resources.
VMware Workstation in Running Kubernetes and Containers
Vmware workstation is a virtualization tool that allows users to create and run virtual machines on a single server. The virtual machines in the VMware workstation work simultaneously with the host machine. Host operating systems can be on windows or Linux allowing users to run Linux on Windows machines or vice versa. Note that you use the Vctl command on Vmware to run and manage containers and the Kubernetes cluster from either windows PowerShell or command prompt. Vctl is a command line utility on the Vmware workstation that enables managing containers and associated container runtime. With vctl, you can build, push, pull and run containers and images as well as manage system runtime settings. Also, the Vctl utility supports KIND which allows VMware workstations to use vctl containers to run local Kubernetes clusters.
- Vctl command line is only supported by Windows 10 1809 or later.
- Install Vmware workstation on windows
Running Containers and Kubernetes on Windows using VMware Workstation
After successful installation of VMware Workstation player/pro, you will find the executables from C:\Program Files(x86)\VMware\VMware Player for VMware workstation 16 player and C:\Program Files (x86)\VMware\VMware Workstation\ for VMware workstation 16 pro. Note that the Vmware workstation has three executable which include:
a) Containerd.exe: It is the runtime containerd daemon that requires to be started before running any container. It is started on command prompt or PowerShell on windows using the vctl system start command.
b) Containerd-shim-crx-v2.exe: It has the role of launching a new containerd-shim-crx-v2 process when a new container is started. Thus, it acts as an adapter between the containerd daemon and the container in CRX VM.
c) Bin/vctl.exe: This is the command line utility running in the foreground and accepts the user’s input to the containerd daemon.
The image below shows the location of Containerd.exe and Containerd-shim-crx-v2.exe on Windows 10/11.
Vctl.exe is in the bin folder of Vmware workstation files as illustrated below.
Starting the vctl Utility on Windows 10/11
Vmware workstation utilizes vctl Utility to run containers and Kubernetes cluster. Let’s start by opening either command prompt or PowerShell.
Search for power shell from the windows search bar and click on open or run as an administrator.
Also, you can use the Command prompt by searching and clicking on open or run as an administrator from Windows 10/11.
Now, from either command prompt or PowerShell, change the current working directory to VMware workstation 16 player or pro to navigate through your VMware Workstation path default. For VMware Workstation 16 Pro use the following command to access vctl:
cd 'C:\Program Files (x86)\VMware\VMware Workstation\'
As for VMWare workstation 16 Player, run this command and access vctl:
cd 'C:\Program Files (x86)\VMware\VMware Player'
Confirm that the vctl utility is working using the vctl command.
Results after running the vctl command should be as shown below.
PS C:\Program Files (x86)\VMware\VMware Player> vctl vctl - A CLI tool for the container engine powered by VMware Player vctl Highlights: • Build and run OCI containers. • Push and pull container images between remote registries & local storage. • Use a lightweight virtual machine (CRX VM) based on VMware Photon OS to host a container. Use 'vctl system config -h' to learn more. • Easy shell access into virtual machine that hosts container. See 'vctl execvm’. USAGE: vctl COMMAND [OPTIONS] COMMANDS: build Build a container image from a Dockerfile. create Create a new container from a container image. describe Show details of a container. exec Execute a command within a running container. execvm Execute a command within a running virtual machine that hosts container. help Help about any command. images List container images. inspect Return low-level information on objects. kind Get system environment ready for vctl-based KIND. login Log in to a registry.
Check whether the container runtime is running or stopped using the vctl system info command.
vctl system info
In most cases, when you are using vctl for the first time, the container runtime will read as stopped.
PS C:\Program Files (x86)\VMware\VMware Player> vctl system info Container runtime is stopped. Use 'vctl system start' to start. Container runtime path: C:\Program Files (x86)\VMware\VMware Player\containerd.exe Log file: C:\Users\user\.vctl\containerd.log Log level: info Config: C:\Users\user\.vctl\config.toml Virtual machine CPU (cores): 2 Virtual machine memory (MB): 1024 Kubernetes node CPU (cores): 2 Kubernetes node memory (MB): 2048 Host network: vmnet8 Storage root folder: C:\Users\user\.vctl\storage
Start the vctl utility using the following command.
vctl system start
Here are the expected results when the vctl utility is started.
PS C:\Program Files (x86)\VMware\VMware Player> vctl system start Preparing storage... Container storage has been prepared successfully under C:\Users\user\.vctl\storage Preparing container network... Container network has been prepared successfully using vmnet: vmnet8 Launching container runtime... Container runtime has been started.
If you check on the status of vctl container runtime, it should be running.
PS C:\Program Files (x86)\VMware\VMware Player> vctl system info Container runtime is running. Use 'vctl system stop' to stop. Container runtime path: C:\Program Files (x86)\VMware\VMware Player\containerd.exe Process ID: 2256 Log file: C:\Users\user\.vctl\containerd.log Log level: info Config: C:\Users\user\.vctl\config.toml Virtual machine CPU (cores): 2 Virtual machine memory (MB): 1024 Kubernetes node CPU (cores): 2 Kubernetes node memory (MB): 2048 Host network: vmnet8 Storage root folder: C:\Users\user\.vctl\storage
After you have started the vctl utility, you can confirm the container storage by changing to the vctl directory.
Use the dir command to check the vctl container storage loaction.
PS C:\Users\user\.vctl> dir Directory: C:\Users\user\.vctl Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 8/5/2022 12:38 PM .r d----- 8/6/2022 1:25 PM bin d----- 8/6/2022 2:23 PM network d----- 8/5/2022 12:27 PM opt d----- 8/6/2022 2:23 PM storage -a---- 8/6/2022 9:22 PM 160 config.json -a---- 8/6/2022 9:22 PM 245 config.toml -a---- 8/6/2022 9:22 PM 139 config.yaml -a---- 8/6/2022 9:42 PM 201225 containerd.log
Using Vmware Workstation Vctl to Run Containers
Let’s use hello-world as our example and start by pulling it from a repository using the following command.
vctl pull hello-world
PS C:\Program Files (x86)\VMware\VMware Player> vctl pull hello-world INFO Pulling from index.docker.io/library/hello-world:latest ─── ────── ──────── REF STATUS PROGRESS ─── ────── ──────── index-sha256:53f1bbee2f52c39e41682ee1d388285290c5c8a76cc92b42687eecf38e0af3f0 Done 100% (2562/2562) manifest-sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 Done 100% (525/525) layer-sha256:2db29710123e3e53a794f2694094b9b4338aa9ee5c40b930cb8063a1be392c54 Done 100% (2479/2479) config-sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412 Done 100% (1469/1469) INFO Unpacking hello-world:latest... INFO done
Proceed by running the hello-world container.
vctl run hello-world
The command above will run successfully and display the following information.
PS C:\Program Files (x86)\VMware\VMware Player> vctl run hello-world INFO container hello-world-0bc4 started Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
Pulling an Image using Vmware Workstation
Let’s try something else such as pulling the Nginx image.
vctl pull nginx
Nginx image will be deployed as illustrated below.
PS C:\Program Files (x86)\VMware\VMware Player> vctl pull nginx INFO Pulling from index.docker.io/library/nginx:latest ─── ────── ──────── REF STATUS PROGRESS ─── ────── ──────── index-sha256:ecc068890de55a75f1a32cc8063e79f90f0b043d70c5fcf28f1713395a4b3d49 Done 100% (1862/1862) manifest-sha256:f26fbadb0acab4a21ecb4e337a326907e61fbec36c9a9b52e725669d99ed1261 Done 100% (1570/1570) layer-sha256:1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7 Done 100% (31366757/31366757) layer-sha256:05396a986fd3f3739cc890e30a2ed78e377c6a2b24d9f0ebe99ff3349aedc603 Done 100% (603/603) layer-sha256:baf2da91597d101646b307b706d06b048862192b127f74b1079d374d902e32f4 Done 100% (25348083/25348083) config-sha256:b692a91e4e1582db97076184dae0b2f4a7a86b68c4fe6f91affa50ae06369bf5 Done 100% (7653/7653) layer-sha256:b1349eea8fc5b5eebb633c2cd79fc24a915fcb00279de24684bb07e349e8eab3 Done 100% (1391/1391) layer-sha256:6a17c8e7063d97ef72e89f7d4673935ff9a2b7c179bea1726852399219118f65 Done 100% (891/891) layer-sha256:27e0d286aeab484653fdf0f736d5f7a2fbcc572e387ec8a1d6ccf0e74b6bfefc Done 100% (664/664) INFO Unpacking nginx:latest... INFO done
Verify the images you have pulled and get them listed as illustrated below.
PS C:\Program Files (x86)\VMware\VMware Player> vctl images ──── ───────────── ──── NAME CREATION TIME SIZE ──── ───────────── ──── kindest/[email protected]:98cf5288864662e37115e362b23e4369c8c4a408f99cbc06e58ac30ddc721600 2022-08-06T14:05:27+03:00 481.5 MiB nginx:latest 2022-08-06T13:32:59+03:00 54.1 MiB hello-world:latest 2022-08-05T12:34:24+03:00 6.9 KiB
Running a Container with Vmware Workstation
Now that you have pulled an image, you can run a container using the vctl command line. For instance, I will run myContainer container as an example. The -d flag while running a container, helps in detaching the host console session from the running container.
vctl run --name myContainer -d nginx
The container above will run as follows.
PS C:\Program Files (x86)\VMware\VMware Player> vctl run --name myContainer -d nginx INFO container myContainer started and detached from current session
See the container status using the vctl ps command.
PS C:\Program Files (x86)\VMware\VMware Player> vctl ps ──── ───── ─────── ── ───── ────── ───────────── NAME IMAGE COMMAND IP PORTS STATUS CREATION TIME ──── ───── ─────── ── ───── ────── ───────────── myContainer nginx:latest /docker-entrypoint.s... 192.168.53.129 n/a running 2022-08-06T13:50:14+03:00
Start or Stop a Container using Vmware workstation
If you want to free up resources, consider stopping the container. Replace myContainer with the name of your container.
vctl stop myContainer
The container will stop after using the command above.
PS C:\Program Files (x86)\VMware\VMware Player> vctl stop myContainer >> INFO container myContainer has been stopped
Also, you can start the container.
vctl start myContainer -d
The stopped container will now start successfully.
PS C:\Program Files (x86)\VMware\VMware Player> vctl start myContainer -d INFO container myContainer started and detached from current session
Use kind Kubernetes with vctl on Windows 11/10
Vmware workstation allows you to use vctl to deploy a kind-based Kubernetes cluster. To use kind, ensure the container runtime is started from either command prompt or PowerShell.
vctl system start
After getting the results below, you can now proceed.
C:\Windows\system32> vctl system start Preparing storage... Container storage has been prepared successfully under C:\Users\user\.vctl\storage Preparing container network... Container network has been prepared successfully using vmnet: vmnet8 A running container runtime was found and reused.
Now launch kind using vctl to deploy Kubernetes clusters.
After running the above command, a new command prompt or PowerShell window will open. Note that closing the window will lead to losing the vctl-based KIND context. Continue using KIND commands on the new window, for instance, we will create a basic cluster.
kind create cluster
Results after using the above command:
C:\Windows\system32> kind create cluster Creating cluster "kind" ... • Ensuring node image (kindest/node:v1.19.1) 🖼 ... ✓ Ensuring node image (kindest/node:v1.19.1) 🖼 • Preparing nodes 📦 ... ✓ Preparing nodes 📦 • Writing configuration 📜 ... ✓ Writing configuration 📜 • Starting control-plane 🕹️ ... ✓ Starting control-plane 🕹️ • Installing CNI 🔌 ... ✓ Installing CNI 🔌 • Installing StorageClass 💾 ... ✓ Installing StorageClass 💾 Set kubectl context to "kind-kind" You can now use your cluster with: kubectl cluster-info --context kind-kind Have a nice day! 👋
Vctl allows you to delete a kind cluster.
kind delete cluster
The kind cluster will be deleted as shown below.
C:\Windows\system32> kind delete cluster Deleting cluster "kind" ...
Vmware Workstation Vctl Cleanup
After you are done using the vctl command line, run the command below to clean up and stop all running containers and container runtime.
vctl system stop -f
The cleaning up of vctl residual environment data will take place.
PS C:\Program Files (x86)\VMware\VMware Player> vctl system stop -f Terminate container myContainer ... INFO container myContainer has been stopped Terminating container runtime... SUCCESS: The process with PID 7292 has been terminated. Container runtime has been stopped.
Verify if container runtime has stopped.
vctl system info
The status of the container runtime should read as stopped.
C:\Windows\system32> vctl system info Container runtime is stopped. Use 'vctl system start' to start. Container runtime path: C:\Program Files (x86)\VMware\VMware Player\containerd.exe Log file: C:\Users\user\.vctl\containerd.log Log level: info Config: C:\Users\user\.vctl\config.toml Virtual machine CPU (cores): 2 Virtual machine memory (MB): 1024 Kubernetes node CPU (cores): 2 Kubernetes node memory (MB): 2048 Host network: vmnet8 Storage root folder: C:\Users\user\.vctl\storage
Vmware workstation allows you to run different instances of the operating systems on a single host machine. Additionally, Vmware workstation 16 player/Pro when installed on Windows 10/11, will allow you to run containers and Kubernetes. This guide has taken you through how you can use the vctl command line offered by the VMware workstation to assist in the managing of Kubernetes clusters and containers. In case you have any questions, leave a message in the comment section.