Hi all, I have installed a CentOS6 lxc guest under a Debian 8.x LXC host. All it is working ok but I can't change the hostname for the centos6 lxc container (it is using the same hostname from Debian host). I have modifyed HOSTNAME under /etc/sysconfig/network and /etc/hosts file, but it doesn't works. Do I need to change anything else?? Thanks.
Greetings, ----- Original Message -----> I have installed a CentOS6 lxc guest under a Debian 8.x LXC host. > All it is working ok but I can't change the hostname for the centos6 lxc > container (it is using the same hostname from Debian host). I have > modifyed HOSTNAME under /etc/sysconfig/network and /etc/hosts file, > but it doesn't works. > > Do I need to change anything else??If I remember correctly, it is generally set in /etc/sysconfig/network on a regular EL6 host. If that isn't working when run within an LXC container on a Debian host... ask whoever packaged up the LXC container template you used. There is a lot of variance in LXC from one distro to another. Some recipes say to install from a .tar.gz file (which I prefer to call an OS Template) others say to do a chroot install using a distro's native package manager. My point is, that LXC tools and methods really vary... and I don't think the CentOS project can help much in this situation. For containers, I've been using OpenVZ (now called OpenVZ Legacy while they work on the newer Virtuozzo 7) for 10 years now... and they have a standard set of OS Templates for a range of distros and everything (generally) works as it is supposed to... and even with that... the CentOS Project isn't interested in helping OpenVZ users running CentOS containers... because it uses a non-CentOS provided kernel and management tools... although the recommended OpenVZ Legacy hostnode distro is CentOS 6.x. Virtuozzo 7 is its own distro rebased from CentOS 7. One container technology they are interested in supporting is Docker (app containers) especially when using the official CentOS Docker images built/provided by the CentOS Project... running on a CentOS host. TYL, -- Scott Dowdle 704 Church Street Belgrade, MT 59714 (406)388-0827 [home] (406)994-3931 [work]
On 21.01.2016 15:44, C. L. Martinez wrote:> Hi all, > > I have installed a CentOS6 lxc guest under a Debian 8.x LXC host. All > it is working ok but I can't change the hostname for the centos6 lxc > container (it is using the same hostname from Debian host). I have > modifyed HOSTNAME under /etc/sysconfig/network and /etc/hosts file, > but it doesn't works. > > Do I need to change anything else??These Files only persist the hostname. To actually set it live you have to call "hostname <hostname>". Your shell prompt will not change unless you log out and log in again though simply executing "hostname" without parameters should output the correct name right away. Keep in mind though that setting the hostname in a container requires explicit support for the UTS namespace on the host: http://man7.org/linux/man-pages/man7/namespaces.7.html If the host doesn't support the UTS namespace for its guests or this feature is not configured for the guest in question then setting the hostname in the guest is not possible. Regards, Dennis
On Thu, Jan 21, 2016 at 6:25 PM, Dennis Jacobfeuerborn <dennisml at conversis.de> wrote:> On 21.01.2016 15:44, C. L. Martinez wrote: >> Hi all, >> >> I have installed a CentOS6 lxc guest under a Debian 8.x LXC host. All >> it is working ok but I can't change the hostname for the centos6 lxc >> container (it is using the same hostname from Debian host). I have >> modifyed HOSTNAME under /etc/sysconfig/network and /etc/hosts file, >> but it doesn't works. >> >> Do I need to change anything else?? > > These Files only persist the hostname. To actually set it live you have > to call "hostname <hostname>". Your shell prompt will not change unless > you log out and log in again though simply executing "hostname" without > parameters should output the correct name right away. > > Keep in mind though that setting the hostname in a container requires > explicit support for the UTS namespace on the host: > > http://man7.org/linux/man-pages/man7/namespaces.7.html > > If the host doesn't support the UTS namespace for its guests or this > feature is not configured for the guest in question then setting the > hostname in the guest is not possible. > > Regards,Thanks Dennis. I have tried to fix using "hostname" command but after reboot, returns to be the same hostname as Debian host. Debian kernel has UTS enabled ...
Possibly Parallel Threads
- Hostname inside lxc container
- autpfs + nfs stuck on stat() inside libvirt lxc 1.2.18
- signal for shutdown in lxc driver
- Re: How to monitor a lxc container started by libvirt_lxc from inside ?
- Re: How to monitor a lxc container started by libvirt_lxc from inside ?