# How to access service variables in dockerfile template

**URL:** <https://forums.balena.io/t/how-to-access-service-variables-in-dockerfile-template/2760>\
**Category:** Product support\
**Tags:** docker\
**Created:** [March 19, 2018, 11:42pm UTC](https://forums.balena.io/t/how-to-access-service-variables-in-dockerfile-template/2760 "2018-03-19T23:42:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajbeaven](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/ajbeaven/32/870_2.png) [@ajbeaven](https://forums.balena.io/u/ajbeaven)\
**Post date:** [March 19, 2018, 11:42pm UTC](https://forums.balena.io/t/how-to-access-service-variables-in-dockerfile-template/2760/1 "2018-03-19T23:42:59Z")

</div>

Is it possible to set ARG variables in the dockerfile templates based on a service variables in [Resin.io](http://Resin.io)? I’d like to do something like this:

```
ARG sas_token
RUN curl -o node.zip "https://####.blob.core.windows.net/releases/####/node.zip$sas_token"

```

Unfortunately this doesn’t appear to be working currently. When I run

```
RUN echo "The token is '$sas_token'"

```

The output is

> The token is ‘’

---

<div class="post-metadata">

**Author:** ![sqweelygig](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/sqweelygig/32/150_2.png) [@sqweelygig](https://forums.balena.io/u/sqweelygig)\
**Post date:** [May 10, 2018, 10:42am UTC](https://forums.balena.io/t/how-to-access-service-variables-in-dockerfile-template/2760/4 "2018-05-10T10:42:30Z")

</div>

The build happens independently of the eventual environment of the device. We do have two solutions for providing configuration to inform the build process that isn’t stored in the repo, one done and one in the works.

1. You could build locally and then provide the resin infrastructure with the built artefact, it will then deploy this to the fleet. ( [https://docs.resin.io/reference/cli/#deploy-appname-image-](https://docs.resin.io/reference/cli/#deploy-appname-image-) and [https://resin.io/blog/multi-stage-docker-builds-for-tiny-iot-images/](https://resin.io/blog/multi-stage-docker-builds-for-tiny-iot-images/) )
2. We are working on the ability to provide build time env vars, and have linked this topic to that so that here should be updated when progress is made.

---

<div class="post-metadata">

**Author:** ![ajbeaven](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/ajbeaven/32/870_2.png) [@ajbeaven](https://forums.balena.io/u/ajbeaven)\
**Post date:** [May 10, 2018, 10:58am UTC](https://forums.balena.io/t/how-to-access-service-variables-in-dockerfile-template/2760/5 "2018-05-10T10:58:44Z")

</div>

2 sounds like just what we need so I’m very much looking forward to that happy day. Thanks for your work!

---

<div class="post-metadata">

**Author:** ![ajbeaven](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/ajbeaven/32/870_2.png) [@ajbeaven](https://forums.balena.io/u/ajbeaven)\
**Post date:** [May 10, 2018, 11:08am UTC](https://forums.balena.io/t/how-to-access-service-variables-in-dockerfile-template/2760/7 "2018-05-10T11:08:16Z")

</div>

Regarding 1, sorry I misread that a bit at first. This is a good idea, however as we’re using VSTS for CI/CD, it becomes a bit more difficult. You guys should totally create a third-party VSTS release task (and probably an Octopus Deploy task) that uses the Resin CLI to push an artifact directly to Resin. That would make deploying so much better than it is now.

---

<div class="post-metadata">

**Author:** ![afitzek](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/afitzek/32/359_2.png) [@afitzek](https://forums.balena.io/u/afitzek)\
**Post date:** [May 10, 2018, 11:53am UTC](https://forums.balena.io/t/how-to-access-service-variables-in-dockerfile-template/2760/8 "2018-05-10T11:53:36Z")

</div>

Thanks for your feedback. I created an internal feature request for a VSTS release task and also linked it to this topic, so we can update it with news from the feature request.
