Changing Docker hostnames—with namespaces!
That gives me an idea: I can't change the hostname from a container because of limited capabilities. But I could totally launch a new process in the same namespace, and this new process would have no capability limits—so it could change the hostname. And that change would be shared with the container! Let's try it!
Source: Changing Docker hostnames—with namespaces!, an article by Dave Vasilevsky.