File directory:
.env
docker-compose.yml
.env:
# root directory
ROOT_PATH=./services
# Project Path
WWW_PATH=./www
# nginx
NGINX_WWW_DIR=$(WWW_PATH)
docker-compose.yml
- ${NGINX_WWW_DIR}:/data/www:rw
Error: named volume “www.path:/data/www.rw” isused in service “nginx” but no declaration was found in the volumes section.
Question:
The constant defined in the. env file is invalid, how can it be made valid?
NGINX_WWW_DIR=$(WWW_PATH)
The brackets here should be removed.
=>
NGINX_WWW_DIR=$WWW_PATH
Or change to braces
NGINX_WWW_DIR=${WWW_PATH}
However, according to docker volume mapping rules, it is best to use absolute paths, that is
NGINX_WWW_DIR=$PWD/$WWW_PATH
-v should only accept absolute path.