Home > Blockchain >  forward exact environment variables from host to container
forward exact environment variables from host to container

Time:03-15

I am finding my self repeating like this:

services:
  noice-service:
    environment:
      - EUREKA_SERVICE_URL=${EUREKA_SERVICE_URL}
      - ZIPKIN_BASE_URL=${ZIPKIN_BASE_URL}
      - CONFIG_SERVER_URL=${CONFIG_SERVER_URL}

I have defined these env vars in .env file and some in another scripts and I just want to pass their exact value in container. Is there any way quicker way of achieving this without any custom shell script as entrypoint ?

CodePudding user response:

You can pass the variables directly:

# .env
DOTENV=foo
# docker-compose.yml
version: "3.7"
services:
  busybox:
    image: busybox
    command: ["env"]
    environment:
      - DOTENV
      - ANOTHER

And run ANOTHER=bar docker-compose up.

  • Related