Best way to determine either device name or host name in a container


I’m trying to map a naming convention against my devices. When flashing all of them I specified a “hostname” on the config.json which would be their unique identifiers. My Node application then grabs the hostname and identifies itself to my external server. However, it seems that docker is detecting and using the container hostname ie. odroid-xu4-1d6259c.

Wondering what would be easiest/best way to handle this? My understanding is that the RESIN_HOST_CONFIG_* variables are available container side. Within my Node application how can I gain access to this value?

UPDATE: I’ve learned that I can use resin device rename to change the device name. So rather than depend on hostname I’m going to use the device name from Resin. So to revise my question, how can I easily snag the device name of from within my Node app (running inside the container?).



Hi dblaise,

Device’s name is contained in the following environment variable: RESIN_DEVICE_NAME_AT_INIT.

You can read in your application the value of the variable.

From the shell you can see it with this command:



Hi @spancea ,

Coming back to this issue, it seems like whenever I run echo $RESIN_DEVICE_NAME_AT_INIT within terminal on the device, it returns an empty string/line carriage and obviously not the correct hostname.

Also I’m wondering if this same variable is accessible WITHIN the application container itself? For example if I were to pass it into my Node environment like so, should I not see the follow?


Thanks in advance,





is available only in the container. So you should be able to use it anyway you would use any other variable in your container