When I SSH onto a running Docker container in a Kubernetes cluster and run os.getenv("HOSTNAME")
from within a python interpreter, I am able to see the name of the deployment being used.
But if I try and run os.getenv("HOSTNAME")
in a script that gets run from the Dockerfile
, the env-var is null
.
Is this expected? Is there some workaround here?
UPDATE: I tried to get the contents from /etc/hostname
instead and to my surprise I got debuerreotype
. After some googling I saw that that is the base Debian image in use and apparently it passes that name as the hostname
- Opened an Issue with them in the meantime
- (I still don't understand why I get the correct value when I SSH into the container though)