at least for Debian and Ubuntu LXC containers setting up the hostnmae of the container through lxc.utsname doesn’t seem to work. The hostname is always set to LXC_NAME. I tried to change the hostname from within the container using ‘hostname’ command. It works until I restart the container. Then the name is reset back to LXC_NAME.
LXC_NAME seems to be environmental variable available to container hooks (see https://linuxcontainers.org/fr/lxc/manpages/man5/lxc.container.conf.5.html) and it is correctly populated with the container name. I tried to set the hostname through the hooks but it didn’t work.
When I started the container in foreground I can see that the hostname is set to LXC_NAME. I tried the same experiment on ubuntu VM and there the hostname was properly taken from lxc.utsname and set properly during the booting sequence (see the second sequence).
Is it a bug in lxc or something specific to OpenWRT / lxc version or even to Omnia?
Begging of the booting sequence:
root@turris:/srv/lxc/u1# lxc-start -F -n u1 Failed to insert module 'autofs4': No such file or directory Failed to insert module 'unix': No such file or directory systemd 229 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN) Detected virtualization lxc. Detected architecture arm. Welcome to Ubuntu 16.04.1 LTS! Set hostname to <LXC_NAME>'.
From ubuntu VM:
radek@ubuntu-server:~$ lxc-start -F -n xenial lxc-start: utils.c: open_without_symlink: 1620 No such file or directory - Error examining efi in /usr/lib/x86_64-linux-gnu/lxc/sys/firmware/efi/efivars systemd 229 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN) Detected virtualization lxc. Detected architecture x86-64. Welcome to Ubuntu 16.04 LTS! Set hostname to <xenial>.