Linux Container can't set hostname with FQDN

shawly

Member
Nov 8, 2015
25
2
23
So I set up a Ubuntu container with the hostname "test", when I started the container and typed in hostname -f it just shows "test".
Also the entry within the /etc/hosts file just has 127.0.1.1 test in it, not the full domain name which should be test.ho.me.

So I've set the hostname directly to test.ho.me, but it still sets the hostname just to test, why?
I also tried to change the DNS Domain to ho.me but it still won't work...

Code:
proxmox-ve: 4.1-39 (running kernel: 4.2.8-1-pve)
pve-manager: 4.1-22 (running version: 4.1-22/aca130cf)
pve-kernel-4.2.6-1-pve: 4.2.6-36
pve-kernel-4.2.8-1-pve: 4.2.8-39
lvm2: 2.02.116-pve2
corosync-pve: 2.3.5-2
libqb0: 1.0-1
pve-cluster: 4.0-36
qemu-server: 4.0-64
pve-firmware: 1.1-7
libpve-common-perl: 4.0-54
libpve-access-control: 4.0-13
libpve-storage-perl: 4.0-45
pve-libspice-server1: 0.12.5-2
vncterm: 1.2-1
pve-qemu-kvm: 2.5-9
pve-container: 1.0-52
pve-firewall: 2.0-22
pve-ha-manager: 1.0-25
ksm-control-daemon: 1.2-1
glusterfs-client: 3.5.2-2+deb8u1
lxc-pve: 1.1.5-7
lxcfs: 2.0.0-pve2
cgmanager: 0.39-pve1
criu: 1.6.0-1
zfsutils: 0.6.5-pve7~jessie
 
Last edited:
Ok, tested this here on my containers. It is the same. For me it's not a problem. I set the fqdn in dnsservers. But you are right, it would be nice when is possible to set the fqdn in lxc too.
To set an other DNSdomain it is depending on your DHCPserver. Or you set ip's staticly, the in works as you enter it. Tested here, works fine.
 
We only set the FQDN when we also know an IP address.
Yes, most installers also apply the FQDN to 127.0.1.1 at installation, but remember, this only happens once at installation.
With PVE the network configuration is applied at every start, which means we'd be forcing the FQDN into /etc/hosts for a loopback address every time you start the container.
Newer pve-container packages (like the one you have) only edit a comment-marked subsection of the hosts file, so you can already add the entry manually and it won't disappear.
However, adding it automatically means you will not be able to *remove* it (other than manually after every start), and so we'd be forcing the fqdn to resolve to 127.0.1.1.
Now DHCP and DNS servers can be combined and configured with a domain name, and by not forcing the FQDN to resolve to 127.0.1.1 you can then allow the container to get its DHCP-assigned address via the DNS server from its fqdn.
You could argue that for this setup you shouldn't configure the FQDN in PVE, but likewise I could ask why you would use an FQDN with DHCP?
But we're always open to better alternatives as long as they make sense. But I fear changing this would satisfy some users and upset others.
 
Well, I "fixed" this problem by giving my network adapters static IPs, so I'm fine.

But I noticed, that my DNS search domain in the resolv.conf (of my host) always resets to "internal.example.com", I've tried setting it under the Proxmox DNS tab and also directly within the resolv.conf, but after a while it just resets to internal.example.com again, why??
 
On the host? That sounds like debianism.
Are you using the resolvconf package? (It comes as a dependency of various other packages and debian people have this weird convention that anything you install is automatically started against your will, in this case screwing with your resolv.conf... fun times)
 
Nope, the resolvconf package isn't installed..

Edit: I just fixed it, I looked into the dnsmasq config of my router, and the DHCP domain was set to internal.example.com, I feel stupid now lol.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!