mastodon.ar.al is one of the many independent Mastodon servers you can use to participate in the fediverse.
This is my personal fediverse server.

Administered by:

Server stats:

1
active users

Aral Balkan

Am I missing something or should hostnamectl not have a --user mode similar to systemctl? (It doesn’t currently.)

@aral no, because a system's hostname is global.

@eliasp But it could still give you information about it without allowing you to change it. systemctl --user list-machines does, for example.

That said, still not sure if that’d just be more confusing or more consistent…

@eliasp And, actually no, so systemctl --user list-machines is giving me the hostname of my container, not the host. And yet, I see no way of changing that. Hmm…

@eliasp That is: (from within rootful Podman container via distrobox)

cat /etc/hostname

dev.ar.al

systemctl --user list-machines

NAME
fedora-distrobox-root-36.dev.ar.al (host)

@aral @eliasp normally you set a container hostname up in the initialization script i.e. `-h=xxxxx`, in podman at least, I assume docker is the same, not sure about others

@paul @eliasp Yeah. This is more for the server I’m writing to automatically bind to the hostname if one isn’t manually specified. It’s not a biggie, I can just read /etc/hostname directly. I was just thinking there would be a way to get that information from hostnamectl :)

@aral @eliasp ah, OK, I see
Other containers I have used use a mandatory environment variable to set a "bind_address" or something similar - removing the need for checking the actual hostname dynamically
A fallback to actual hostname would be good in some cases though

@aral the fact, that "list-machines" provides output is most likely the inconsistency here, as machines are also global.
The difference between #systemd's "--system" and "--user" mode is, whether something is managed within a user's resources and/or session, like user units/services running within a user's login/desktop session.
This has nothing to do with a users permissions to control services in the system context, for which privileges are granted via #DBus through #PolicyKit

@aral wouldn't anything controlled by hostnamectl be system-wide so a --user mod wouldn't be needed/desired?
I could be wrong, but that's how I see it

@paul I’m thinking for inside a container that has its own /etc/hostname…

@aral I believe the container would still need to be initialized with a hostname as /etc/hostname would be ephemeral and ultimately not an ideal way to configure a hostname for a container

@paul Indeed. Thankfully I only need to read it, not set it. My intuition was that hostnamectl would support that.