You can pass hostnames in docker compose easily with
hostname: myhostname
Sometimes you can use container names too
container_name: myapp
It is that easy ☺️
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.
Rules:
Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.
No spam posting.
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.
Don't duplicate the full text of your blog or github here. Just post the link for folks to click.
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
No trolling.
Resources:
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
You can pass hostnames in docker compose easily with
hostname: myhostname
Sometimes you can use container names too
container_name: myapp
It is that easy ☺️
I'm asking about LXC containers, not Docker containers.
Okay this is easy too to set a hostname on debian or ubuntu Container:
hostnamectl set-hostname myname
root@syncthing ~# hostnamectl status
Failed to connect to bus: No such file or directory
Try this
apt-get install libpam-systemd
Restart LXC afterwards and try again. Let me know if it works now 🐱
I don't have any knowledge about the specific containers, but the way this works on my Linux distro is via the:
send host-name "(hostname)";
option in dhclient.conf
. Maybe you could try explicitly setting that option?
That's part of what's confusing me: none of the containers even have an /etc/dhcp/dhclient.conf
(and I don't think it's anywhere else either because $PATH_DHCLIENT_CONF
is unset).
The hostname resolution might be being done via mdns (https://en.m.wikipedia.org/wiki/Multicast_DNS). That is seperate to your actual DNS server, and I don't think you can centrally disable it. You would have to disable Avahi/ZeroConf/Bonjour on your computer to prevent resolution, or find a way to prevent the containers registering themselves?
https://linux.die.net/man/1/avahi-browse - might help you determine if it's being registered via mdns.
I’ll give you a pointer, the rest is up to you how to apply that in LXC
https://www.cyberciti.biz/faq/howto-get-linux-static-dhcp-address/
https://linuxcontainers.org/lxc/manpages/man5/lxc.container.conf.5.html
Maybe this can point you in the right direction.
I'm not familiar with LXC - do you put together your container from scratch kinda like a FreeBSD jail?
Where is that DHCP server? Are you sure they get actual DHCP leases?
Typically Docker's internal resolution is basically just injecting the hostnames in /etc/hosts
, but Docker also supports macvlan and macvtap networks too which can expose a container network directly on the network.
But I think 99% of containers just use the default bridge network. I never heard of a Docker container running a DHCP client, most containers run the app process directly and don't do a full boot.
Where is that DHCP server? Are you sure they get actual DHCP leases?
The DHCP server is dnsmasq running on my OpenWRT router.
The "Active DHCP Leases" table has entries for the Syncthing and the Nextcloud containers (the former with the hostname listed as "syncthing" and the latter with it listed as "?"). Weirdly, it does not have an entry for the Mediaserver container, even though that container is getting a valid IP.
I also looked through the system logs and found DHCP-related messages for each (Nextcloud is .120, Mediaserver is .159, and Syncthing is .191):
Fri Jul 28 22:47:28 2023 daemon.info dnsmasq-dhcp[4023]: DHCPDISCOVER(br-lan) be:d2:c2:da:ba:fc
Fri Jul 28 22:47:28 2023 daemon.info dnsmasq-dhcp[4023]: DHCPOFFER(br-lan) 192.168.0.120 be:d2:c2:da:ba:fc
Fri Jul 28 22:47:28 2023 daemon.info dnsmasq-dhcp[4023]: DHCPDISCOVER(br-lan) be:d2:c2:da:ba:fc
Fri Jul 28 22:47:28 2023 daemon.info dnsmasq-dhcp[4023]: DHCPOFFER(br-lan) 192.168.0.120 be:d2:c2:da:ba:fc
Fri Jul 28 22:47:28 2023 daemon.info dnsmasq-dhcp[4023]: DHCPREQUEST(br-lan) 192.168.0.120 be:d2:c2:da:ba:fc
Fri Jul 28 22:47:28 2023 daemon.info dnsmasq-dhcp[4023]: DHCPACK(br-lan) 192.168.0.120 be:d2:c2:da:ba:fc
Wed Jul 26 21:45:18 2023 daemon.info dnsmasq-dhcp[4023]: DHCPDISCOVER(br-lan) a6:b6:02:9b:bd:e5
Wed Jul 26 21:45:18 2023 daemon.info dnsmasq-dhcp[4023]: DHCPOFFER(br-lan) 192.168.0.159 a6:b6:02:9b:bd:e5
Wed Jul 26 21:45:18 2023 daemon.info dnsmasq-dhcp[4023]: DHCPREQUEST(br-lan) 192.168.0.159 a6:b6:02:9b:bd:e5
Wed Jul 26 21:45:18 2023 daemon.info dnsmasq-dhcp[4023]: DHCPACK(br-lan) 192.168.0.159 a6:b6:02:9b:bd:e5
Wed Jul 26 21:45:14 2023 daemon.info dnsmasq-dhcp[4023]: DHCPDISCOVER(br-lan) 1e:44:37:54:4a:f8
Wed Jul 26 21:45:14 2023 daemon.info dnsmasq-dhcp[4023]: DHCPOFFER(br-lan) 192.168.0.191 1e:44:37:54:4a:f8
Wed Jul 26 21:45:14 2023 daemon.info dnsmasq-dhcp[4023]: DHCPDISCOVER(br-lan) 1e:44:37:54:4a:f8
Wed Jul 26 21:45:14 2023 daemon.info dnsmasq-dhcp[4023]: DHCPOFFER(br-lan) 192.168.0.191 1e:44:37:54:4a:f8
Wed Jul 26 21:45:14 2023 daemon.info dnsmasq-dhcp[4023]: DHCPREQUEST(br-lan) 192.168.0.191 1e:44:37:54:4a:f8
Wed Jul 26 21:45:14 2023 daemon.info dnsmasq-dhcp[4023]: DHCPACK(br-lan) 192.168.0.191 1e:44:37:54:4a:f8 syncthing
Typically Docker’s...
Again, this post is about LXC containers running directly in Proxmox, NOT DOCKER.