LightSith
LightSith

Reputation: 927

forward exact environment variables from host to container

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 ?

Upvotes: 0

Views: 306

Answers (1)

Ron van der Heijden
Ron van der Heijden

Reputation: 15080

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.

Upvotes: 2

Related Questions