vSphere Integrated Containers Part IV: docker run a Container-VM
Instantiate a nginx cVM
Now that we´ve become more familiar with the Virtual Container Host, it´s time to run our first Container-VM on it. The following example will show you how easy it is to instantiate an Nginx Web Server container-image.
We first pull
down the image from Docker Hub to our Datastore by using docker -H 192.168.100.222:2376 --tls pull vmwarecna/nginx
.
You´ll see some running tasks in your vCenter taskbar under Recent Tasks. Validate the downloaded image with docker -H 192.168.100.222:2376 --tls images
.
|
|
Alright! This was successful and by runnig the following command, the VIC Engine will deploy a Nginx Container-VM with 512MB vRAM (-m
) which will listen to port (-p
) 8080.
|
|
Let´s check if our container is up and running. First in vCenter:
…and second via command line:
|
|
|
|
Just like any other Container Host, virtual or physical, you´ll reach your container via the Container Host IP-Address and port. I intended to show the same in my example before we configure a dedicated Container Network afterwards. We can reach the Nginx Web Server site via the VCH IP-Address and port 8080.
If you´re wondering why I always used -H vch-ip-address --tls
in my example that´s because I´ve not “exported” my VCH through it´s IP-Address and port yet. We can do this by the following:
|
|
After we´ve exported the host, we can go the classical way and use commands like: docker pull
, docker images
, docker ps -a
etc. To get a complete list of all available and supported docker commands you´ve to go here:
VIC - Supported Docker Commands
A dedicated Network for Conatiners
I´ve mentioned in the Networking-Part of this post, that I´ll come back to the point where I´ll configure a Container Network to an existing VCH. As a prerequisite we have to create a new Distributed Port Group on our vDistributed Switch and ensure that all other network related configuration (e.g. VLAN) are set. I´ve gave my new dPG the name vic-container.
As also mentioned we´ll make use of the vic-machine configure
option to add the new network to our VCH. Before we begin, we need to know the internal ID of it. Use vic-machine inspect
with the virtual machine name of your VCH:
|
|
The output will show us the internal ID which is in my case vm-212:
|
|
Okay, now that we have the ID we can continue with adding the new container network by using vic-machine configure
:
|
|
I´ve used the option --timeout 5m
because I ran in a timeout without it. I´m pretty sure this was performance related to my nested environment. But anyway! The configuration was successful and we can validate it with vic-machine inspect
:
|
|
|
|
At the end we need to validate the functionality as well and we´ll deploy a new Nginx but this time with the dedicated Container Network vic-container-network and without declaring the port.
|
|
There you go! :-)
World Cup 2018 CLI Dashboad Container
Just before coming to the end of my VIC series and because it´s Worldcup time, I´d like to show you a nice World Cup 2018 CLI dashboard by Cédric Blondeau running in a container.
|
|
Isn´t that cool?! :-) Try it out!
Previous articles:
vSphere Integrated Containers Part III: Deployment of a Virtual Container Host
vSphere Integrated Containers Part II: vSphere Client Plug-In