A.Hamza
A.Hamza

Reputation: 229

Docker Compose says $PWD variable not set Windows

I am new to docker. I currently have docker-compose.yml where volume I want to mount my current directory to '/usr/share/data' in the container. So something like:

volumes:
    - ${PWD}/data:/usr/share/data/

I am using windows with a Linux Subsystem and want to know why isn't it able to get the PWD variable. The same code on a Linux machine works fine. Please tell me how to set the environment PWD. Do I need to do it manually or can i do it using the same docker-compose file. Using . instead of ${PWD} gives no directory error and I have seen many forums saying that it is a windows problem.

Upvotes: 8

Views: 15511

Answers (2)

Neo Anderson
Neo Anderson

Reputation: 6372

In order to share Windows folders with Docker containers when running, you first need to configure the Shared Drives option in Docker settings:

Right click on docker app > Settings > Shared drives > Check D:

Then . and ${PWD} should work in compose:

volumes:
    - ./data:/usr/share/data/

Upvotes: 2

anemyte
anemyte

Reputation: 20296

You need to use ${PWD} instead of {$PWD}. You can also use dot . instead of ${PWD}.

Upvotes: 3

Related Questions