且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在没有env vars的情况下从该主机上的docker容器内部获取docker主机的主机名

更新时间:2022-06-13 00:44:52

您可以将主机名作为环境变量传递。您也可以挂载/ etc,以便可以使用/ etc / hostname。但是我同意Vitaly,这不是容器IMO的预期用例。

You can pass in the hostname as an environment variable. You could also mount /etc so you can cat /etc/hostname. But I agree with Vitaly, this isn't the intended use case for containers IMO.