Creating Virtual Machines and Containers
This section explains how to create new Virtuozzo virtual machines and containers using the prlctl create command. The options you should pass to this command differ depending on whether you want to create a virtual machine or container.
Choosing OS EZ Templates for Containers
Before creating a container, you need to choose an OS EZ template it will be based on.
Listing OS EZ Templates
To find out which OS EZ templates are already installed on the hardware node and cached (i.e. ready to be used), you can use the vzpkg list command. For example:
| |
The timestamp next to an OS EZ template indicates when the template was cached.
Adding the -O option to the vzpkg list command, you can list only those OS EZ templates which are installed but not cached. You can also add the --with-summary option to display brief template descriptions:
| |
Installing and Caching OS EZ Templates
Some of the supported OS EZ templates may not be preinstalled, so you may need to perform additional steps before you can create containers based on these templates. To list templates available for installation in the official remote repositories, run the following command:
| |
To prepare a template for container creation, do the following:
Install the template package. For example:
1# vzpkg install template sles-15-x86_64Configure additional template parameters if needed. Some of the EZ templates may require specific preparation steps that depend on the operating system. To prepare, for example, a SLES 15 template for container creation, you additionally need to do the following:
Obtain twelve keys from the installed system by copying them in the
etc/zypp/repos.d/directory:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25cd /etc/zypp/repos.d/ grep 'https://updates.suse.com/SUSE/Products/SLE-Module-Basesystem/15-SP2/x86_64/\ product?'; *.repo $SLES_KEY_REL grep 'https://updates.suse.com/SUSE/Updates/SLE-Module-Basesystem/15-SP2/x86_64/\ update?'; *.repo $SLES_KEY_UPD grep 'https://updates.suse.com/SUSE/Products/SLE-Product-SLES/15-SP2/x86_64/\ product?'; *.repo $SLES_KEY_PRO grep 'https://updates.suse.com/SUSE/Updates/SLE-Product-SLES/15-SP2/x86_64/\ update?'; *.repo $SLES_KEY_PRU grep 'https://updates.suse.com/SUSE/Products/SLE-Module-Server-Applications/15-SP2/\ x86_64/product?' *.repo $SLES_SERVER_REPO grep 'https://updates.suse.com/SUSE/Updates/SLE-Module-Server-Applications/15-SP2/\ x86_64/update?' *.repo $SLES_SERVER_UPDATES grep 'https://updates.suse.com/SUSE/Products/SLE-Module-Web-Scripting/15-SP2/x86_64/\ product?'; *.repo $SLES_KEY_WEB_PRO grep 'https://updates.suse.com/SUSE/Updates/SLE-Module-Web-Scripting/15-SP2/x86_64/\ update?'; *.repo $SLES_KEY_WEB_UPD grep 'https://updates.suse.com/SUSE/Products/SLE-Module-Development-Tools/15-SP2/\ x86_64/product?'; *.repo $SLES_KEY_DEV_PRO grep 'https://updates.suse.com/SUSE/Updates/SLE-Module-Development-Tools/15-SP2/\ x86_64/update?'; *.repo $SLES_KEY_DEV_UPD grep 'https://updates.suse.com/SUSE/Products/SLE-Module-Legacy/15-SP2/x86_64/\ product?'; *.repo $SLES_KEY_LEG_PRO grep 'https://updates.suse.com/SUSE/Updates/SLE-Module-Legacy/15-SP2/x86_64/\ update?'; *.repo $SLES_KEY_LEG_UPDAdd the obtained keys to the
/etc/vztt/url.mapfile:1 2 3 4 5 6 7 8 9 10 11 12echo "$SLES_KEY_REL <obtained_key_1>" >> /etc/vztt/url.map echo "$SLES_KEY_UPD <obtained_key_2>" >> /etc/vztt/url.map echo "$SLES_KEY_PRO <obtained_key_3>" >> /etc/vztt/url.map echo "$SLES_KEY_PRU <obtained_key_4>" >> /etc/vztt/url.map echo "$SLES_SERVER_REPO <obtained_key_5>" >> /etc/vztt/url.map echo "$SLES_SERVER_UPDATES <obtained_key_6>" >>/ etc/vztt/url.map echo "$SLES_KEY_WEB_PRO <obtained_key_7>" >> /etc/vztt/url.map echo "$SLES_KEY_WEB_UPD <obtained_key_8>" >> /etc/vztt/url.map echo "$SLES_KEY_DEV_PRO <obtained_key_9>" >> /etc/vztt/url.map echo "$SLES_KEY_DEV_UPD <obtained_key_10>" >> /etc/vztt/url.map echo "$SLES_KEY_LEG_PRO <obtained_key_11>" >> /etc/vztt/url.map echo "$SLES_KEY_LEG_UPD <obtained_key_12>" >>/ etc/vztt/url.mapYou may also need to set the SUSE repository credentials (obtained from the SUSE Customer Center) in the
/etc/vztt/url.mapfile as follows:1 2$SLES_LOGIN <user> $SLES_PASSWORD <password>Copy certificates from the installed system to the
/vz/template/sles/15/x86_64/config/os/default/files/directory:1 2trust extract --format=openssl-directory --filter=ca-anchors --overwrite /tmp/certs/ scp -r /tmp/certs/* root@<your-node-ip>:/vz/template/sles/15/x86_64/config/os/default/files/
Create the template cache:
1# vzpkg create cache sles-15-x86_64
Now you can create containers based on the prepared template.
Creating Containers
To create a container, use the prlctl create command as follows:
| |
Virtuozzo Server will create a new container with the name MyCT using the default parameters from the global configuration file /etc/vz/vz.conf.
If you want to create a container with a guest OS different from the default specified in the global configuration file, add the --ostemplate option after the prlctl create command. For example:
| |
All container contents will be stored in this container’s private area. To find out where the private area is located, use the prlctl list command as follows:
| |
Take note of the following:
- The first time you install an operating system in a container, its cache is created. To create a cache, you need to have an active Internet connection to access repositories that contain packages for the respective operating system. You can also set up a local package repository and use this repository to provide packages for your operating system. A local package repository is also required for some commercial distributions (e.g., for Red Hat Enterprise Linux).
- For information on creating containers with preinstalled applications, see Using Golden Images.
Prerequisites for Creating Red Hat Enterprise Linux Containers
Creating Red Hat Enterprise Linux containers requires certificates to be present on the host. You will need a working Red Hat Enterprise Linux 7, 8, or 9 installation. You can use the same certificates for these three versions.
Do the following before creating such containers:
Find the certificate paths in the repository file, for example,
/etc/yum.repos.d/redhat.repo:1 2 3sslcacert = /etc/rhsm/ca/redhat-uep.pem sslclientkey = /etc/pki/entitlement/4662537897317115958-key.pem sslclientcert = /etc/pki/entitlement/4662537897317115958.pemCopy these certificates to
/etc/rhel/on the host where you will be creating Red Hat Enterprise Linux containers.Rename the copied certificates as follows:
1 2sslclientkey.pem sslclientcert.pem
Creating Virtual Machines
Creating a new virtual machine means creating a VM configuration based on a distribution you specified. To create VMs, use the prlctl create command. For example:
| |
This command creates a configuration for a virtual machine MyVM, adjusts it for running the CentOS 7 guest OS, and places all the required files in the /vz/vmprivate/<UUID> directory.
Once the virtual machine configuration is ready, you will need to install a supported guest OS in it (e.g., via VNC as described in Enabling VNC Access to Virtual Machines and Containers).
prlctl set --device-set fdd0 --image <image_file>. The images are located in /usr/share/vz-guest-tools/ and are typically named to match the guest OS name. For Windows Server 2012 (not R2), however, choose floppy_win8.vfd.When choosing a distribution to install, have in mind that Virtuozzo Server supports VM guest initialization via cloud-init, so you can perform some of the initial configuration tasks on stopped virtual machines. To be able to use this feature, you can install a “cloud-enabled” distribution instead of a regular one. For more information, see Using cloud-init for Virtual Machine Guest Initialization.
Supported Guest Operating Systems
The list of guest operating systems supported in virtual machines and containers is provided in the Virtuozzo Server Supported Guest Operating Systems Guide.