# Not defined env vars in microservice app

**URL:** <https://forums.balena.io/t/not-defined-env-vars-in-microservice-app/2825>\
**Category:** Product support\
**Created:** [March 27, 2018, 10:11pm UTC](https://forums.balena.io/t/not-defined-env-vars-in-microservice-app/2825 "2018-03-27T22:11:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcozar](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/jcozar/32/472_2.png) [@jcozar](https://forums.balena.io/u/jcozar)\
**Post date:** [March 27, 2018, 10:11pm UTC](https://forums.balena.io/t/not-defined-env-vars-in-microservice-app/2825/1 "2018-03-27T22:11:51Z")

</div>

I have not seen this behaviour in resin docs, and it seems unexpected for me.

In the context of a microservices application, if an environment var, let’s say MY\_VAR is not defined as service variable in resin, the env var MY\_VAR is set to “$MY\_VAR”. I expect that, as well as it happens in docker-compose, that the env var MY\_VAR is set to blank string.

---

<div class="post-metadata">

**Author:** ![lekkas](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/lekkas/32/78_2.png) [@lekkas](https://forums.balena.io/u/lekkas)\
**Post date:** [June 11, 2018, 8:11pm UTC](https://forums.balena.io/t/not-defined-env-vars-in-microservice-app/2825/4 "2018-06-11T20:11:19Z")

</div>

Hi,

Is this still an issue with the latest resinOS version (Resin OS 2.12.7+rev1)? Do you have a minimal test case and `docker-compose.yml`, so that we can try to reproduce it?

Thanks!

---

<div class="post-metadata">

**Author:** ![jcozar](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/jcozar/32/472_2.png) [@jcozar](https://forums.balena.io/u/jcozar)\
**Post date:** [June 11, 2018, 10:27pm UTC](https://forums.balena.io/t/not-defined-env-vars-in-microservice-app/2825/5 "2018-06-11T22:27:30Z")

</div>

Hi,

I have checked it right now, and yes it does.

My docker-compose.yml is this:

```auto
version: '2.1'
services:
  watchdog:
    build:
      context: ./myservice
      environment:
          MY_VAR: $MY_VAR

```

_myservice_ is a folder with a Dockerfile using `FROM resin/raspberrypi3-python:3.6-slim`. The service just runs a python script with this code inside:

```auto
import os

if __name__ == ' __main__':
    print(os.getenv("MY_VAR"))

```

The result is that, if I define an env var in resin named “MY\_VAR” it prints its value. However, if I do not define the variable MY\_VAR in resin, it prints literally: `$MY_VAR`.

Thank you for your attention!
