Previous page

Next page

Locate page in Contents

Print this page

Obtaining Server ID from Inside a Container

The default Virtuozzo installation does not allow users inside a Container to obtain any information specific to the host the Container is running on. The reason is that no Container shall have knowledge about the corresponding server. A Container can be transparently migrated to another server, and if this Container runs any applications depending on the particular server, these applications might fail after the migration.

In some situations, however, you need to provide a unique server ID to some applications. For example, you might want to license your application per server. In this case, after the migration your customer will need to re-apply the license for your application.

Virtuozzo provides access to the unique server ID via the /proc/vz/hwid file. The default Virtuozzo installation makes this file accessible to Containers from 1 to 100 (i.e. Containers with reserved IDs). It is possible to change this range in the global configuration file (vz.conf). For example, this is the way to make the file visible in Containers from 1 to 1000:

# vi /etc/vz/vz.conf

VZPRIVRANGE="1 1000"

# prlctl exec 101 cat /proc/vz/hwid

0C3A.14CB.391B.6B69.02C9.4022.3E2F.CAF6

The above example illustrates accessing the server ID from Container 101.