# Check dev or prod image inside a service

**URL:** <https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230>\
**Category:** balenaOS\
**Created:** [July 8, 2021, 5:37am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230 "2021-07-08T05:37:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![scarlyon](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@scarlyon](https://forums.balena.io/u/scarlyon)\
**Post date:** [July 8, 2021, 5:37am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/1 "2021-07-08T05:37:02Z")

</div>

Is there an easy way to figure out inside a service that the current image is prod or dev?

---

<div class="post-metadata">

**Author:** ![cywang117](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cywang117/32/6307_2.png) [@cywang117](https://forums.balena.io/u/cywang117)\
**Post date:** [July 8, 2021, 6:18am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/2 "2021-07-08T06:18:13Z")

</div>

Hi,

Currently, the Supervisor API is able to return OS version via the GET `/v1/device` endpoint, but not variant (prod/dev). A Supervisor endpoint would be an easy way to access this kind of information, and as one of the Supervisor maintainers, rest assured that we are working on this. We’ll notify you when an endpoint matching your needs is available in production, then you may upgrade your Supervisor via self-serve upgrades ([Self-service Supervisor Upgrades - Balena Documentation](https://www.balena.io/docs/reference/supervisor/supervisor-upgrades/)).

As for what you can do right now, to get device information not available from the Supervisor API, you can query the balena API by adding the `io.balena.features.balena-api` label to your service (see [docker-compose.yml fields - Balena Documentation](https://www.balena.io/docs/reference/supervisor/docker-compose/#labels)) and curl-ing the API from the service with the following:

```auto
 curl -X GET "$BALENA_API_URL/v6/device?\$filter=startswith(uuid,'$BALENA_DEVICE_UUID')" --compressed --silent -H "Authorization: B
earer $BALENA_API_KEY"

```

You’ll receive a JSON response which contains `os_variant`, which you can extract with a package like `jq`. Let us know if this works for you!

Regards,  
Christina

---

<div class="post-metadata">

**Author:** ![scarlyon](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@scarlyon](https://forums.balena.io/u/scarlyon)\
**Post date:** [July 8, 2021, 7:09am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/4 "2021-07-08T07:09:14Z")

</div>

Hi, @cywang117

Thanks for your quick reply!

Hmm, no reply from the curl command above… Seems my supervisor version is too old?

```auto
root@balena:/usr/src/app# curl -X GET --header "Content-Type:application/json" "$BALENA_SUPERVISOR_ADDRESS/v1/device?apikey=$BALENA_SUPERVISOR_API_KEY"
{"api_port":48484,"ip_address":"10.0.1.69","os_version":"balenaOS 2.80.8+rev1","mac_address":"B8:27:EB:77:43:65","supervisor_version":"12.8.8","update_pending":false,"update_failed":false,"update_downloaded":false,"commit":"9424da8ca143882cb5a0466ed3c73f12","status":"Downloaded","download_progress":null}

```

I cannot upgrade its version as we are using openBalena instead of balenaCloud…

From which version is the `/v6/device` API supported?

Cheers,  
Shane.

---

<div class="post-metadata">

**Author:** ![cywang117](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cywang117/32/6307_2.png) [@cywang117](https://forums.balena.io/u/cywang117)\
**Post date:** [July 8, 2021, 7:38am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/5 "2021-07-08T07:38:41Z")

</div>

Sorry, I should clarify - the above cURL is for the balena cloud API, not the Supervisor API. The Supervisor API is available on each device and is accessible from containers if you use the `io.balena.features.supervisor-api` label. v12.8.8 is relatively new as well.

When you were running the command, did you have the `io.balena.features.balena-api` label set for the service you’re using to query your openBalena server?

---

<div class="post-metadata">

**Author:** ![cywang117](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cywang117/32/6307_2.png) [@cywang117](https://forums.balena.io/u/cywang117)\
**Post date:** [July 8, 2021, 7:47am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/6 "2021-07-08T07:47:32Z")

</div>

Also, what version of openBalena are you using? Thanks!

---

<div class="post-metadata">

**Author:** ![scarlyon](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@scarlyon](https://forums.balena.io/u/scarlyon)\
**Post date:** [July 8, 2021, 7:59am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/9 "2021-07-08T07:59:18Z")

</div>

Hi, @cywang117

Yes, I had enabled `balena-api` and was able to get the device details. please check above.

And the openBalena server - I am using 3.4.0 at the moment.

Cheers,  
Shane.

---

<div class="post-metadata">

**Author:** ![cywang117](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cywang117/32/6307_2.png) [@cywang117](https://forums.balena.io/u/cywang117)\
**Post date:** [July 8, 2021, 8:09am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/10 "2021-07-08T08:09:24Z")

</div>

Hi Shane,

I’m confused about what you mean regarding the device details snippet you sent - that query was made to the Supervisor API, which is made available with the label of `io.balena.features.supervisor-api`. It’s different than the balena-api label (`io.balena.features.balena-api`) which is needed to query the `/v6/device`endpoint from a container.

To clarify, since you’ve set the `io.balena.features.balena-api` label for your service already, are you following these steps:

1. `balena exec -it YOUR_SERVICE_WITH_BALENA_API_LABEL /bin/bash`
2. To check that the balena-api label was activated for your service, you can run `printenv | grep 'BALENA'`. You should see `BALENA_API_URL` corresponding to your openBalena API server, `BALENA_DEVICE_UUID`, and `BALENA_API_KEY`.
3. Run the previous command `curl -X GET "$BALENA_API_URL/v6/device?\$filter=startswith(uuid,'$BALENA_DEVICE_UUID')" --compressed --silent -H "Authorization: Bearer $BALENA_API_KEY"`

Additionally, `/v6/devices` should be accessible from openBalena version 3.4.0, as it’s quite new.

Apologies for the confusion! 🙂  
Regards,  
Christina

---

<div class="post-metadata">

**Author:** ![scarlyon](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@scarlyon](https://forums.balena.io/u/scarlyon)\
**Post date:** [July 8, 2021, 8:12am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/12 "2021-07-08T08:12:49Z")

</div>

Oh, I am confused! lol

Yeah, will give it a try soon and get back to you!

Thanks!

---

<div class="post-metadata">

**Author:** ![cywang117](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cywang117/32/6307_2.png) [@cywang117](https://forums.balena.io/u/cywang117)\
**Post date:** [July 8, 2021, 8:19am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/17 "2021-07-08T08:19:58Z")

</div>

Thanks! Let us know if it works for you.

---

<div class="post-metadata">

**Author:** ![scarlyon](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@scarlyon](https://forums.balena.io/u/scarlyon)\
**Post date:** [July 8, 2021, 10:02am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/18 "2021-07-08T10:02:59Z")

</div>

@cywang117  
Hmm, no reply from the command… But I can see the env variables inside the container with `printenv | grep BALENA` command…

 ![image](https://global.discourse-cdn.com/balena/original/2X/9/9df0e75e8e2edb3f76e5ac66efc41eaf20c9fd32.png)

Any idea?

---

<div class="post-metadata">

**Author:** ![rcooke-warwick](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@rcooke-warwick](https://forums.balena.io/u/rcooke-warwick)\
**Post date:** [July 8, 2021, 10:21am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/20 "2021-07-08T10:21:20Z")

</div>

Hi there, quite strange that it’s simply returning nothing… Perhaps try running the curl command withou the `--silent` option and see if it gives us an error message

---

<div class="post-metadata">

**Author:** ![scarlyon](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@scarlyon](https://forums.balena.io/u/scarlyon)\
**Post date:** [July 8, 2021, 10:37am UTC](https://forums.balena.io/t/check-dev-or-prod-image-inside-a-service/337230/22 "2021-07-08T10:37:52Z")

</div>

Oh, yes. I had to add `--insecure` parameter to ignore the SSL issue. Thanks!
