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?

1

2 Answers 2

1

Two options:

environment:
  - DOCKERHOST: ${DOCKERHOST}

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

environment:
  - DOCKERHOST
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.