On Fri, Jan 20, 2017 at 03:19:31PM +0000, Brian Candler wrote:
> Hello,
> 
> What's the mechanism by which when you do "lxc copy foo bar", the "bar" gets
> into /etc/hostname? Is this logic inside lxd itself, or inside cloud-init,
> or somewhere else?
> 
> The reason I ask: I am creating instances whose FQDN is e.g.
> "srv2.campus5.example.com". lxd does not allow dots in container names, so I
> have to give them names like "srv2-campus5" instead. But then that's what
> ends up in /etc/hostname as well.
> 
> Clearly I can just overwrite /etc/hostname and restart the container, but I
> wondered if there was a cleaner way, and that in turn led me to try and find
> out how it gets set in the first place, and I couldn't find it.
> 
> Reading issue #1921, I tried setting lxc.utsname before starting the
> container, but this didn't make a difference:
> 
> $ lxc copy srv-master foobar
> $ lxc config set foobar raw.lxc lxc.utsname=wibble
> $ lxc config set foobar user.fqdn bibble
> $ lxc start foobar
> $ lxc exec foobar bash
> root@foobar:~# hostname
> foobar
> root@foobar:~# cat /etc/hostname
> foobar
> 
> And if I change the profile of srv-master so that it's on a bridge with no
> DHCP service before copying, the copy still seems to pick up the hostname.
> 
> Thanks,
> 
> Brian.

/etc/hostname is generated through a LXD template file.
See metadata.yaml in the image and the templates/ directory.

You could modifiy metadata.yaml for your source container at
/var/lib/lxd/containers/<source>/metadata.yaml to remove the template
for /etc/hostname so that it won't be applied again on copies.

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

Attachment: signature.asc
Description: PGP signature

_______________________________________________
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users

Reply via email to