I have a setup like
backend:
build: backend
ports:
- "80:80"
environment:
PGSTRING: postgres://postgres:examplePW@db:5432/postgres
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: examplePW
As you see, I need to specify examplePW twice. I would want to either
- Randomly generate a string of a specific length, and insert it at both places. or
- Have something like a variables that I define at the start of my docker-compose.yml, which is then inserted into both locations.
That said, I am still required to be able to launch this with docker-compose up - with no other commands ran before, and no other files in my directory, so supplying the password via an environment variable seems not to be possible. Is there any way to achieve what I want?