Mount current directory as a volume in Docker on Windows 10
This works for me in PowerShell:
docker run --rm -v ${PWD}:/data alpine ls /data
In Windows Command Line (cmd
), you can mount the current directory like so:
docker run --rm -it -v %cd%:/usr/src/project gcc:4.9
In PowerShell, you use ${PWD}
, which gives you the current directory:
docker run --rm -it -v ${PWD}:/usr/src/project gcc:4.9
On Linux:
docker run --rm -it -v $(pwd):/usr/src/project gcc:4.9
Cross Platform
The following options will work on both PowerShell and on Linux (at least Ubuntu):
docker run --rm -it -v ${PWD}:/usr/src/project gcc:4.9
docker run --rm -it -v $(pwd):/usr/src/project gcc:4.9