Retrieving hostname from within the container



I’m very simply trying to grab the device hostname within my application. Unfortunately when I SSH into the device and run echo $RESIN_DEVICE_NAME_AT_INIT within the terminal no value is outputted except a new empty line.

If I run the following command to get the host config:
curl "$RESIN_SUPERVISOR_ADDRESS/v1/device/host-config?apikey=$RESIN_SUPERVISOR_API_KEY"
I’m getting:
curl: (3) <url> malformed

Also please note that I’m not looking for the containers hostname, I’m looking to retrieve the devices OR better yet if I can set the hostname of the container based on the parent, that would work as well.

Thanks in advance,



I got a response directly on chat support for this question. Posting here for other users benefit:

The $RESIN_DEVICE_NAME_AT_INIT is available inside the container and not inside the hostOS. So if you use the dashboard to access the console please make sure to access the application and not the hostOS when reading the variable.