[lxc-users] unique container id

U.Mutlu for-gmane at mutluit.com
Thu Feb 5 17:32:19 UTC 2015


Serge Hallyn wrote, On 02/05/2015 06:05 PM:
> Quoting U.Mutlu (for-gmane at mutluit.com):
>> Serge Hallyn wrote, On 02/05/2015 04:47 PM:
>>> Quoting U.Mutlu (for-gmane at mutluit.com):
>>>> U.Mutlu wrote, On 02/01/2015 05:16 PM:
>>>>> Hi,
>>>>> how can a program or a shell script get the unique ID of the container
>>>>> it is running inside? For example the name of the container.
>>>>
>>>> Hi people,
>>>> has nobody an idea for this?
>>>
>>> Sigh.  Try ls -li /proc/self/ns/pid
>>
>> Hi Serge,
>> I think this is only an ephemeral ID, isn't it?
>> I rather need a persistent ID for identifying the container.
>> It would even suffice to get the name of the container (from within
>> the container). Is this possible?
>
> You have to do it yourself.  If the hostname.domainname is not
> sufficient, you could have a startup hook (maybe lxc.hook.mount)
> write a container id of your choice into, say,
> $LXC_ROOTFS_MOUNT/etc/lxc_id.
>
> -serge

Ok, thx, using the hook mechanism this looks feasible.

cu
Uenal




More information about the lxc-users mailing list