Docker: mount the current directory as a volume on Windows 10
Codemia Knowledge Hub ·
To mount the current directory as a volume on Windows 10, pass -v with your shell's current-path variable: ${PWD} in PowerShell, %cd% in Command Prompt, and $(pwd) in Git Bash or WSL. Using the wrong variable for your shell is the most common reason the mount fails silently or shows up as an empty directory in the container.
Bind mounts vs named volumes
Docker connects host storage to containers with either bind mounts or named volumes. Mounting the current directory is a bind mount: the host path maps directly into the container's filesystem, and changes on either side are visible on the other immediately.
Files created in /app inside the container appear on the host, and host edits appear in the container without a restart.
| 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 editing code on the host and seeing the change instantly in the container, a bind mount is the right choice.
Syntax for each Windows shell
| 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
Git Bash converts Unix-style paths to Windows paths automatically, which can break volume mounts. If Docker complains that a path is not valid, add an extra leading slash to turn off conversion:
Or set MSYS_NO_PATHCONV:
Docker Desktop file sharing
Docker Desktop needs access to the drive that holds your project.
Enabling file sharing
- Open Docker Desktop and go to Settings (gear icon).
- Go to Resources, then File Sharing.
- Make sure the drive with your project (typically
C:\) is listed and enabled. - Click Apply and Restart.
If you skip this, Docker mounts an empty directory without any error. The container starts, but the mounted path is empty, which is one of the most confusing failures on Windows.
WSL 2 vs Hyper-V backend
Docker Desktop on Windows 10 runs on either WSL 2 or Hyper-V. With WSL 2 (recommended), file sharing is automatic for paths under \\wsl$\ and most C:\Users\ paths. With the older Hyper-V backend, you must configure shared drives yourself.
To see which backend you use, open Settings, then General, and look at "Use the WSL 2 based engine."
Examples
Node.js with live reload
Mount the project and let a watcher such as nodemon reload on changes:
Edit index.js on Windows and nodemon in the container picks up the change.
Python
Docker Compose
In docker-compose.yml, . means the current directory, resolved relative to the directory containing the compose file:
This avoids typing -v by hand and behaves the same in every shell, because Compose resolves the path itself.
Read-only mounts
If the container should read files but never change them, such as configuration files, append :ro:
The container can read everything in /app/config but cannot create, modify or delete files there.
Debugging an empty or broken mount
If ls /app shows an empty directory, the likely causes are file sharing not enabled for that drive, the path variable not expanding in your shell, or Git Bash rewriting the path.
File permissions
Windows and Linux handle permissions differently, so files created in the container may show unexpected ownership on the host and the reverse. That is usually fine in development. For production containers, set the user explicitly:
Mistakes that break the mount
Wrong shell variable. ${PWD} works in PowerShell but not Command Prompt, and %cd% works in Command Prompt but not PowerShell. Mixing them up is the top cause of failed mounts.
File sharing disabled. The mount succeeds, the directory is empty, and no error is shown. Check Settings, then Resources, then File Sharing.
Git Bash path mangling. MINGW turns /app into C:\Program Files\Git\app. Use MSYS_NO_PATHCONV=1 or double the slash on the container path.
Paths outside the user directory. By default Docker Desktop shares only paths under C:\Users. Mounting from D:\projects requires adding that path in the file sharing settings.
Slow node_modules. Bind mounts on Windows are slower than native filesystem access because Docker translates between NTFS and the Linux filesystem. Keep node_modules inside the container with a named volume:
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 interview problems on this topic
- Design a Container Orchestration System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design GitHub Actions: solution and walkthrough
- Design a Serverless Architecture Framework: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.