Hostname not updating after re template

adamjseed

New Member
Feb 13, 2012
17
0
1
Hi all,

I have a question about Hostname/re templating a Openvz container.

Up until now I have been going into a container file system from the host
Code:
cd /var/lib/vz/private/101
and issuing a tar command to create a template after I have installed a few things.
Code:
tar -cvzpf /var/lib/vz/template/cache/test1_amd64.tar.gz .
This seems to work apart from the hostname is not updating. In partular im using the centos-6-x86_64.tar.gz from http://openvz.org/Download/template/precreated

So if I make a container from centos-6-x86_64.tar.gz called test1 the hostname will be test1 and there will be entries in the /etc/hosts file to reflect this. If I then create a new template from that machine by the method above and then use it to create a new container called test2 the hostname will still be test1 but the /etc/hosts file is updated to test2

Is there anyway that I can make the hostname update automatically? as the old hostname will not be reflected in the host file.
 
I just tested this and got the same behaviour - I create a template by using the same command as you, then when I use that template in a new instance the hotname remains the same.