Invalid docker .env file definition WWW_PATH

File directory:
.env
docker-compose.yml

.env:

-sharp 
ROOT_PATH=./services
-sharp 
WWW_PATH=./www

-sharp nginx
NGINX_WWW_DIR=$(WWW_PATH)

docker-compose.yml

- ${NGINX_WWW_DIR}:/data/www:rw

: Named volume "WWW_PATH:/data/www:rw" is used in service "nginx" but no declaration was found in the volumes section.
question:

.env?
Dec.08,2021

 NGINX_WWW_DIR=$(WWW_PATH)

you should remove the parentheses here

= >

 NGINX_WWW_DIR=$WWW_PATH
 

or change to curly braces

 NGINX_WWW_DIR=${WWW_PATH}
 
 

but according to the docker volume mapping rules, it is best to use the absolute path, that is,

 
 NGINX_WWW_DIR=$PWD/$WWW_PATH
 
 
 
-v should only accept absolute path.

I think of combining variables myself in docker-compose.yml.

such as $(ROOT_PATH) $(SUB_PATH)

Menu