0

I have a .env file like this:

PROJECT_DIR=./test_dir
SUB_DIR=$(PROJECT_DIR)/sub_dir

And docker-compose.yml file like this:

version: '3.5'

services:
    service_nginx:
        image: nginx
        volumes:
            - ${SUB_DIR}:/var/www/html

But I can't use $SUB_DIR in docker-compose.yml file for volume, I got error like this:

ERROR: Named volume "$(PROJECT_DIR)/sub_dir:/var/www/html:rw" is used in service "service_nginx" but no declaration was found in the volumes section.
saderi
  • 11
  • 2

1 Answers1

1

Update your env file as follows

export PROJECT_DIR=./test_dir
export SUB_DIR=$(PROJECT_DIR)/sub_dir

Then run the following command to read the varialbes;

. ./.env

Then deploy the stack from same terminal session.

Nitish
  • 597
  • 1
  • 4
  • 9