Multicontainer docker-compose.yml & resin environment variables


#1

I have a simple docker-compose.yml file. I’d like to use the RESIN_MACHINE_NAME variable to define which docker image to pull. But I can’t seem to get it working. Here’s my config:

---
version: '2'
services:
  sidekick:
    restart: always
    privileged: true
    image: 'company/sidekick-resin:${RESIN_MACHINE_NAME}'

I’ve tried lots of combinations of ‘resin:’ + %%RESIN_MACHINE_NAME%% and other various approaches. Is there a right way to do this?


Multiple devices, single Application
#5

Hi, one note is that RESIN_MACHINE_NAME is not an environment variable, but a Dockerfile template variable, only available at the moment in Dockerfile.template files as %%RESIN_MACHINE_NAME%% (note, this is not the ${VARNAME} environment variable formatting), see more in the Dockerfile Templates docs.

We are planning to add support to template variables to docker-compose.yml, but the current workaround is the way that is shows in our getting started project:

You could basically create separate sidekick folder (or any other name) with just a Dockerfile.template of

FROM company/sidekick-resin:%%RESIN_MACHINE_NAME%%

(if that image has all your CMD and other setup as well). And in docker-compose.yml you’d use

services:
  sidekick:
    restart: always
    privileged: true
    build: ./sidekick

#13

Cool, that works for me. Thanks @imrehg!