• Home
  • Category: Servers

Customizing an openvz container for Proxmox

After getting my own dedicated server, I found myself repeating certain tasks on the container every time, like setting my locale, timezone, adding aliases to .bashrc, updating and upgrading packages. I thought it was time I had a go at customizing my own Debian minimal template.

Here’s how to go about modifying an openvz template.

First, create a container in proxmox, let its container id be 100.
Set the IP and other details in the Proxmox panel, inclluding choosing which template it is to be based on.

Start the container:

vzctl start 100

Check that network is ok:

vzctl exec 100 ping -n -c 1 google.com

Enter the container:

vzctl enter 100

Now do all that you have to do on the container, including modifying the apt sources list, setting timezone, installing any additional programs or removing existing ones, adding any public keys etc.

Remove logs like .bash_history.

Once you’re done, exit the container.


Stop the container and remove its IP:

vzctl stop 100
vzctl set 100 --ipdel all --save

Now create the new template file:

cd /vz/private/100
tar --numeric-owner -czf /vz/template/cache/debian-7.0-x86_64_India.tar.gz .

Clean up:

vzctl destroy 100
rm -f /etc/vz/conf/100.conf.destroyed

OpenVZ Wiki

Changing password for a container:
vzctl set 101 –userpasswd root:test