0

I am using docker-compose like this:

version: "2"
services:
  3dominator:
    build: .
    image: 3dominator:0.1
    container_name: 3dominator
    environment:
      NODE_ENV: development
      DB_ENV: container
      DOCKERHOST: $${DOCKERHOST}
    ports:
      - "3004:3004"
    volumes:
      - ./src:/app/src
    links:
      - 3dominatordb
      - 3dominatores
     ...
     ...

I want to pass a variable DOCKERHOST from my linux environment to docker container environment.

How to do that?

durisvk10
  • 549
  • 1
  • 6
  • 11
  • Possible duplicate of [How to use environment variables in docker compose](http://stackoverflow.com/questions/29377853/how-to-use-environment-variables-in-docker-compose) – Rao Mar 23 '17 at 18:44

2 Answers2

1

Two options:

environment:
  - DOCKERHOST: ${DOCKERHOST}

Or since you are using the same variable name, you can shorten that to:

environment:
  - DOCKERHOST
BMitch
  • 231,797
  • 42
  • 475
  • 450
0

You're almost there. Just remove one of the $ signs:

https://docs.docker.com/compose/compose-file/#variable-substitution

By having two dollar signs, you're preventing Compose from substituting the shell value for the variable.

Djelibeybi
  • 78
  • 7