For how to install and configure vSphere Integrated Containers I recently wrote here. Today we will create our own base docker image (with CentOS 7 system) with any application, and load it into the registry (image repository) on Harbor. In addition, we will create a persistent volume that will connect to our new container. The topic of VIC is quite new, so there is not much information on the Internet related to it, this article was created as an attempt to systematize the knowledge associated with it.
Why do we have to create our own base image of CentOS 7 when in the Docker Hub is available in stock? All images from the hub are cleared to zero, we will not find there simple things like the vi editor, curl, wget and others and which are sometimes useful. Of course, by putting our own applications we will use our own images, it is good to know how to create and manage them in vSphere environment using Harbor and Admiral. To make the base image, we will need a CentOS 7 machine. We do the following:
export image=/image/rootfs
mkdir -p $image
initialize rpm database
rpm –root $image –initdb
yum reinstall –downloadonly –downloaddir . centos-release
rpm –root $image -ivh centos-release*.rpm
rpm –root $image –import $image/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
yum -y –installroot=$image –setopt=tsflags=’nodocs’ –setopt=override_install_langs=en_US.utf8 install yum
sed -i “/distroverpkg=centos-release/a override_install_langs=en_US.utf8\ntsflags=nodocs” $image/etc/yum.conf
cp /etc/resolv.conf $image/etc
chroot $image /bin/bash <<EOF
yum install -y procps-ng iputils vi mc bindutils wget curl (or what You want)
yum clean all
EOF
rm -f $image/etc/resolv.conf
If we need a proxy then we set it inside $image/etc/yum.conf. Now we have prepared the initial image, we import this image to local repo and run it as a container and see if everything works.
Our container works properly (for now locally on the machine where it was made) to run it on VCH we have to load it into Harbor. On a Linux machine, we create a directory with the name of the machine (VIC) to which we upload the ca.crt file, which is the certificate issued for Harbor (see the first VIC article). Then log into the Harbor to see if the communication is correct.
If everything is ok, we may copy the image from the local machine to Harbor repository (docker push command). In the remote repository is created the default project named library which we will use.
If everything is ok, we pull the container image from Harbor to VCH (VMware Container Host) and check that the image is properly visible.
Before we start the container, we will generate a persistent volumen and connect it to the container.
vCenter view:
We run our own CentOS 7 container with a persistent volume connected to the /etc directory so that our effects will not disappear after the container reboots. Of course, the whole procedure here is just an example of the possibilities that vSphere Integrated Containers brings.