I have to set a environment variable to the absolute path of the docker-compose.yml
file. I tried ${PWD}
(see below). However, as expected, PWD
is the path from where the docker compose command is executed and not the path of the docker-compose.yml
file.
How can I do this?
In case this is not possible, is there a way to configure docker compose that it always changes the PWD
to the location of the docker-compose.yml
file?
services:
environment:
TEST_ENV: ${PWD}/data
use environment file and set the path manually
,use a script to dynamically set the path
,use Docker Compose Override Files
or lastlyuse Docker Compose variable substitution with .env
. apart from these i dont think there are any option , plase check the above and try to meet your requirements.