0

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 ?

LightSith
  • 795
  • 12
  • 27
  • Does this answer your question? [docker-compose build environment variable](https://stackoverflow.com/a/68831814/9208887) – The Fool Mar 14 '22 at 20:46

1 Answers1

2

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.

Ron van der Heijden
  • 14,803
  • 7
  • 58
  • 82