Mount current directory as a volume in Docker on Windows 10
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
To mount the current directory as a volume in Docker on Windows 10, use the -v flag with the appropriate shell variable for the current path. In PowerShell, that is ${PWD}. In Command Prompt, it is %cd%. In Git Bash or WSL, it is $(pwd). The exact syntax depends on which shell you are running, and getting this wrong is the most common reason the mount silently fails or produces an empty directory inside the container.
How Docker Volume Mounts Work
Docker supports two types of mounts for connecting host directories to containers: bind mounts and named volumes. When you mount the current directory, you are using a bind mount. The host path maps directly into the container's filesystem, so changes made on either side are immediately visible to the other.
This is a live, two-way mirror. Files created inside the container at /app appear on the host, and edits made on the host appear inside the container without restarting it.
Bind mount vs named volume
| Feature | Bind Mount | Named Volume |
| Host path required | Yes, you specify the exact directory | No, Docker manages storage location |
| Data persists after container removal | Yes, data stays on host | Yes, data stays in Docker-managed area |
| Performance on Windows | Slower (filesystem translation) | Faster (native Docker storage) |
| Use case | Development (live code editing) | Production (databases, persistent state) |
| Syntax | -v /host/path:/container/path | -v volume_name:/container/path |
For development workflows where you want to edit code on the host and see changes instantly inside the container, bind mounts are the correct choice.
Shell-Specific Syntax Reference
The variable for "current directory" is different across Windows shells. Using the wrong one produces a confusing error or mounts an empty directory.
| Shell | Current Directory Variable | Example Command |
| PowerShell | ${PWD} | docker run -v ${PWD}:/app alpine ls |
| Command Prompt (cmd.exe) | %cd% | docker run -v %cd%:/app alpine ls |
| Git Bash (MINGW) | $(pwd) with MSYS path conversion | docker run -v "$(pwd)":/app alpine ls |
| WSL 2 (Ubuntu) | $(pwd) | docker run -v "$(pwd)":/app alpine ls |
Git Bash path conversion issue
Git Bash on Windows automatically converts Unix-style paths to Windows paths, which can break Docker volume mounts. If you see an error about paths not being valid, prefix the path with an extra slash to disable conversion:
Alternatively, set the MSYS_NO_PATHCONV environment variable:
Docker Desktop Prerequisites
Before volume mounts will work, Docker Desktop must have access to the drive where your project lives.
Enabling file sharing
- Open Docker Desktop and go to Settings (gear icon).
- Navigate to Resources, then File Sharing.
- Ensure the drive containing your project (typically
C:\) is listed and enabled. - Click Apply and Restart.
Without this step, Docker silently mounts an empty directory. The container starts successfully, but the mounted path contains nothing. This is one of the most confusing failure modes on Windows.
WSL 2 backend vs Hyper-V backend
Docker Desktop on Windows 10 can use either WSL 2 or Hyper-V as its backend. With WSL 2 (recommended), file sharing is handled automatically for paths under \\wsl$\ and most C:\Users\ paths. With the older Hyper-V backend, you must explicitly configure shared drives.
Check which backend you are using in Docker Desktop under Settings, then General, then "Use the WSL 2 based engine."
Practical Examples
Node.js development with live reload
Mount your project directory and use a file watcher like nodemon to reload on changes:
Edit index.js on your Windows host, and nodemon inside the container picks up the change automatically.
Python development
Docker Compose
In docker-compose.yml, you can use . to refer to the current directory. Compose resolves it relative to the directory containing the docker-compose.yml file:
This is cleaner than typing the -v flag manually and works consistently across shells because Compose handles path resolution internally.
Read-Only Mounts
If the container should read files but never modify them (for example, mounting configuration files), append :ro to the mount:
The container can read everything in /app/config but cannot create, modify, or delete files there.
Debugging Mount Issues
When a mount does not work as expected, use these steps to diagnose:
If ls /app shows an empty directory, the most likely causes are: file sharing is not enabled for that drive in Docker Desktop, the path variable is not expanding correctly in your shell, or Git Bash is mangling the path.
File Permission Considerations
Windows and Linux handle file permissions differently. Files created by the container may appear with unexpected ownership on the host, and vice versa. For development, this is usually not a problem. For production containers, specify the user explicitly:
Common Pitfalls
Using the wrong shell variable. ${PWD} works in PowerShell but not in Command Prompt. %cd% works in Command Prompt but not in PowerShell. Mixing them up is the number one cause of failed mounts.
File sharing not enabled in Docker Desktop. The mount succeeds but the directory appears empty inside the container. No error is shown. Check Docker Desktop Settings, then Resources, then File Sharing.
Git Bash path mangling. MINGW's automatic path conversion turns /app into C:\Program Files\Git\app. Use MSYS_NO_PATHCONV=1 or double-slash the container path.
Mounting a path outside the user directory. By default, Docker Desktop only shares paths under C:\Users. Mounting from D:\projects requires adding that path to file sharing settings explicitly.
Performance with large node_modules. Bind mounts on Windows are slower than native filesystem access because Docker must translate between NTFS and the Linux filesystem. For node_modules, consider using a named volume to keep them inside the container:
Summary
- Use
-v ${PWD}:/appin PowerShell,-v %cd%:/appin Command Prompt, and-v "$(pwd)":/appin Git Bash or WSL to mount the current directory. - Bind mounts create a live, two-way mirror between host and container filesystems.
- Docker Desktop must have file sharing enabled for the drive containing your project.
- Git Bash users need to handle MSYS path conversion by setting
MSYS_NO_PATHCONV=1or using double slashes. - Docker Compose simplifies volume syntax by accepting
.as the current directory. - Append
:rofor read-only mounts when the container should not modify host files. - For performance-sensitive directories like
node_modules, use a named or anonymous volume instead of a bind mount.
Related reading
- Mount docker host volume but overwrite with container's contents
- Mount host directory with a symbolic link inside in docker container
- Mount non-existing host directory into non-root container
- Mounting directory from host machine to container in Docker
- Mounting kubernetes volume with User permission
- Mounting multiple volumes on a docker container?
- Mounts denied. The paths ... are not shared from OS X and are not known to Docker
- Multiline comments in Dockerfiles

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.