Getting IP address of device

In the summary section of the resin console of each device, you can see that it tells you what the IP ADDRESS is of the current device. Is there an easy way to get this number in a service / host os?

My goal is to record this in an environment variable locally on boot so that my application’s know what the IP address is.

Hey @bgold, you can do this using the Supervisor API from within one of your containers:

curl -X GET --header "Content-Type:application/json" \ "$RESIN_SUPERVISOR_ADDRESS/v1/device?apikey=$RESIN_SUPERVISOR_API_KEY"

This will give you the IP amongst other things; take a look here: https://docs.resin.io/reference/supervisor/supervisor-api/
Note if you’re running multicontainer you need to enable it: https://docs.resin.io/learn/develop/multicontainer/#labels

Hope this helps!

Awesome, thank you sir. This will do.

Would be amazing to see this end up in the RESIN_ Environment Variables at some point. Seem’s useful enough but what do I know haha

Neither RESIN_SUPERVISOR_ADDRESS nor BALENA_SUPERVISOR_ADDRESS appears to be defined in a multicontainer context:

root@jetson-tx2-5f8c609:/usr/src/app/source/barnserv# env | grep RESIN
RESIN_SUPERVISOR_VERSION=9.0.1
RESIN_DEVICE_TYPE=jetson-tx2
RESIN=1
RESIN_APP_LOCK_PATH=/tmp/balena/updates.lock
RESIN_SERVICE_KILL_ME_PATH=/tmp/balena/handover-complete
RESIN_DEVICE_UUID=omitted
RESIN_DEVICE_NAME_AT_INIT=falling-water
RESIN_HOST_OS_VERSION=balenaOS 2.29.2+rev1
RESIN_APP_ID=1366228
RESIN_APP_NAME=Camera_Jetson_Development
RESIN_SERVICE_NAME=barnserv
root@jetson-tx2-5f8c609:/usr/src/app/source/barnserv# env | grep BALENA
BALENA_SUPERVISOR_VERSION=9.0.1
BALENA_DEVICE_TYPE=jetson-tx2
BALENA=1
BALENA_SERVICE_NAME=barnserv
BALENA_APP_NAME=Camera_Jetson_Development
BALENA_APP_ID=1366228
BALENA_DEVICE_UUID=omitted
BALENA_SERVICE_HANDOVER_COMPLETE_PATH=/tmp/balena/handover-complete
BALENA_HOST_OS_VERSION=balenaOS 2.29.2+rev1
BALENA_DEVICE_NAME_AT_INIT=falling-water
BALENA_APP_LOCK_PATH=/tmp/balena/updates.lock

Oh, wait, I see the documentation note about needing to add labels to the docker-compose.yml to enable these.