简体   繁体   中英

Environment variable from docker-compose not being passed to container

I am trying to set an environment variable in my docker-compose file and it is not able to be accessed when running the container.

version: "2"
services:
  newman_runner:
    build:
      context: https://github.com/postmanlabs/newman/tree/develop/docker/images/alpine
      args:
        NEWMAN_VERSION: 4.6.0
    image: postman/newman:alpine
    environment:
      - FOO=BOO
    volumes:
      - ./postman:/etc/newman
    entrypoint: echo ${FOO}
#    command:
#      run /etc/newman/Google_Civic_Information_API.postman_collection.json
#      --env-var API_KEY=${API_KEY}

FOO comes back as Empty and I get the following WARNING after running docker-compose.exe up WARNING: The FOO variable is not set. Defaulting to a blank string. WARNING: The FOO variable is not set. Defaulting to a blank string.

I've tried to set FOO as both an array and a dictionary with similar effects. FOO: BOO vs - FOO=BOO

Any ideas?

I'm on windows at the moment if that makes a difference.

What ended up working was this:

version: "2"
services:
  newman_runner:
    build:
      context: https://github.com/postmanlabs/newman/tree/develop/docker/images/alpine
      args:
        NEWMAN_VERSION: 4.6.0
    image: postman/newman:alpine
    environment:
      - FOO

From there I can export FOO before running docker-compose

export FOO=BOO
docker-compose up

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM