6

Is there any way for me to identify which OpenVZ container I am in, from inside the container? I am working on a setup where OpenVZ machines shall boot the same (read-only) disk image, so I can not configure them individually in the file system. I need a unique identification for each of the virtual servers, to be used by scripts running inside the OpenVZ containers.

(I'm running Debian Lenny, BTW.)

2 Answers2

8

Every container in an OpenVZ host has a unique Container ID, also known as its VEID. From within a container, you should be able to read its VEID like this:

awk '{print $1}' /proc/vz/veinfo

This ID should be constant for a given container, since it is associated with the container's .conf file that configures it for OpenVZ.

1

My first idea would be that you can use the IP or MAC address of each VM to differentiate them and pass that value to your scripts.

jhcaiced
  • 1,638