Installing Containers with OpenVZ

Hands-On Lab

 

Photo of Matthew Pearson

Matthew Pearson

Linux Training Architect II in Content

Length

01:00:00

Difficulty

Intermediate

OpenVZ is an open source containerization solution for Linux that allows you to create independent and isolated containers that look and behave just like regular Linux systems. In this hands-on lab, you are tasked with installing and configuring OpenVZ in order to create multiple Linux containers.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Installing Containers with OpenVZ

Introduction

OpenVZ is an open source containerization solution for Linux that allows you to create independent and isolated containers that look and behave just like regular Linux systems. In this hands-on lab, you are tasked with installing and configuring OpenVZ in order to create multiple Linux containers.

Solution

  1. Begin by logging in to the lab server using the credentials provided on the hands-on lab page:

    ssh cloud_user@PUBLIC_IP_ADDRESS
  2. Become the root user:

    sudo su -

Add the OpenVZ repository and import the GPG signing key

  1. Use wget to install the repository:

    wget -O /etc/yum.repos.d/openvz.repo http://download.openvz.org/openvz.repo
  2. Use rpm to import the signing key:

    rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ

Install the OpenVZ kernel and command line utility, as well as vzquota and ploop

Install the OpenVZ kernel and command line utility, as well as vzquota and ploop. Once the packages are installed, reboot the machine to activate the vzkernel.

  1. Install the required packages:

    yum install -y vzkernel vzctl vzquota ploop
  2. Reboot the host to activate the OpenVZ kernel:

    reboot

Add the CentOS 6 template to the /vz/template/cache directory

  1. Use wget to download the template and place it in the cache directory:

    wget -O /vz/template/cache/centos-6-x86_64.tar.gz https://download.openvz.org/template/precreated/centos-6-x86_64.tar.gz

Create and start a container

Create and start a container that uses container ID 105, has a hostname of dev01, and uses the CentOS 6 operating system with basic configuration.

  1. Use vzctl to create the container:

    vzctl create 105 --hostname dev01 --ostemplate centos-6-x86_64 --config basic
  2. Start the container:

    vzctl start 105

Create and start a second container

Create and start a container that uses container ID 110, has a hostname of test01, and uses the CentOS 6 operating system with basic configuration.

  1. Use vzctl to create the container:

    vzctl create 110 --hostname test01 --ostemplate centos-6-x86_64 --config basic
  2. Start the container:

    vzctl start 110
  3. Verify both containers are up and running:

    vzlist -a

Conclusion

Congratulations — you've completed this hands-on lab!