Docker compose will not find $ PWD environment variable

Here is my docker-compose:

version: '2' services: couchpotato: build: context: ./couchpotato dockerfile: Dockerfile ports: - 5050:5050 volumes: - "${PWD}/couchpotato/data:/home/CouchPotato/data/" - "${PWD}/couchpotato/config:/home/CouchPotato/config/" 

When I run it inside the shell, in the docker-compose.yml directory, I get:

 WARNING: The PWD variable is not set. Defaulting to a blank string. 

and the composition starts with an empty PWD.

I see no errors in the file as shown here: https://docs.docker.com/compose/environment-variables/

+5
source share
1 answer

For this you do not need ${PWD} , you can just make the path relative and compound, it will expand it (one main difference between layout paths and processed docker run ).

 version: '2' services: couchpotato: build: context: ./couchpotato dockerfile: Dockerfile ports: - 5050:5050 volumes: - "./couchpotato/data:/home/CouchPotato/data/" - "./couchpotato/config:/home/CouchPotato/config/" 

As to why compose does not see this variable, it depends on your shell. Compose looks for the exported environment variable, the contents of the .env file, and command line flags for the docker-compose command. If each of them turns out to be empty for the variable, you will receive this warning.

+3
source

Source: https://habr.com/ru/post/1263604/


All Articles