[lxc-users] Setting hostname different than container name

Stéphane Graber stgraber at ubuntu.com
Sat Aug 19 23:43:29 UTC 2017


On Sat, Aug 19, 2017 at 04:48:51PM -0400, Ron Kelley wrote:
> Greetings all,
> 
> Trying to set the container hostname different that the container name.  Editing /etc/hostname and /etc/hosts seems to work on Ubuntu but not on CentOS 6 containers.  What is the proper way to set the hostname so it is persistent among reboots for CentOS containers?  The LXD config guide (https://github.com/lxc/lxd/blob/master/doc/configuration.md) has no mention of a hostname keyword.

I'm not very familiar with RHEL/Centos and indeed couldn't find an easy
way (short of using /etc/rc.local) to set the hostname in a Centos 6
container the way I'd expect it to work...

It looks like centos6 looks at the kernel utsname and if it's already
set, won't change it, no matter what you put in /etc/hostname or
/etc/sysconfig/network. Though maybe I'm missing something and one of
our Red Hat / CentOS users will know how to get around this.


At the LXD level, you can use raw.lxc to force the utsname to another
value and that part does seem to work:

    lxc config set c1 raw.lxc lxc.utsname=some-name

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20170819/213461b8/attachment.sig>


More information about the lxc-users mailing list