OpenVZ/Proxmox - Container to Template

11-07-2014 | Remy van Elst

Table of Contents

This guide will show you how to convert an OpenVZ (Proxmox) container to a template. You can then use this template on any other OpenVZ (or proxmox) host. This can be used either to migrate containers or to create a kind of master image to deploy new hosts from.

This guide is tested on a proxmox machine running proxmox version 3.2.

If you like this tutorial and want to support my website, use this link to order a Digital Ocean VPS:

Login as root to the proxmox machine via ssh.

Get a list of containers using vzlist:

 100         85 running
 101         34 running

I want to create a template of which has ID 100.

You must stop the container before creating the image:

vzctl stop 101
Stopping container ...
Container was stopped
Container is unmounted

Go to the container folder:

cd /var/lib/vz/private/100

Then start the image creation:

tar -cvzpf /var/lib/vz/template/cache/ .

This will place the image in /var/lib/vz/template/cache/ This file can be copied and deployed on another host, or used on the same host as a template.

Tags: bash  kvm  openvz  proxmox  proxmox-ve  ssh  tutorials  virtualization