patternModerate
Docker compose volume syntax valid for Windows and Linux
Viewed 0 times
dockerandsyntaxvalidcomposeforwindowslinuxvolume
Problem
We have developers working on an app using both Windows and Linux. The application is built within a Docker container, and ships a docker-compose specification for the build environment.
The local directory is mounted as a volume:
however this doesn't work in Windows because
My question is:
Can we have a single
The obvious way to do this seems to me to have two docker-compose files, one for each OS.
The local directory is mounted as a volume:
volumes:
- ${PWD}:/tmphowever this doesn't work in Windows because
$PWD is not defined. My question is:
Can we have a single
docker-compose.yml to satisfy both the Windows and Linux developers?The obvious way to do this seems to me to have two docker-compose files, one for each OS.
Solution
Yes. Just use ./ for you current directory that the Docker-compose file is in. Your "working directory" for the compose file is just "./". If you are trying to set a directory below that it would look something like:
There's an example of this in the Docker-Compose documentation here. This approach makes the solution cross-platform as well.
volumes:
./DirectoryIWantToTarget:/tmpThere's an example of this in the Docker-Compose documentation here. This approach makes the solution cross-platform as well.
Code Snippets
volumes:
./DirectoryIWantToTarget:/tmpContext
StackExchange DevOps Q#9002, answer score: 10
Revisions (0)
No revisions yet.