ls: cannot access 'C:/Program Files/Git/data': No such file or directory —
you ran Docker from Git Bash on Windows, and Git Bash rewrote the Linux path
/data into a Windows path before Docker saw it. Prefix the command with
MSYS_NO_PATHCONV=1 and the container gets /data as typed.
The same rewrite breaks bind mounts: the volume is mounted somewhere other than the path you asked for, so the folder looks empty or missing inside the container.
The error
docker run --rm -v "$(pwd)/data:/data" postgres:18 ls /data
ls: cannot access 'C:/Program Files/Git/data': No such file or directory
The message comes from ls inside the container, not from Docker, which is why
searching for a Docker error finds nothing. The give-away is
C:/Program Files/Git in a path that should be Linux-only.
Why it happens
Git Bash runs on the MSYS2 runtime. When it starts a native Windows program such as
docker.exe, it converts every argument that looks like an absolute POSIX path
into a Windows path, so that Windows tools can open files you name the Unix way. In Git
Bash the root / is the Git installation folder, so /data becomes
C:/Program Files/Git/data. That is helpful when a Windows tool has to open a file
on your disk, and wrong for a path that is meant for the Linux side of a container.
Two quick commands show it. Docker passes the argument through untouched, so whatever the container prints is what Git Bash handed over:
docker run --rm postgres:18 echo /data
C:/Program Files/Git/data
MSYS_NO_PATHCONV=1 docker run --rm postgres:18 echo /data
/data
The mount target after the colon in -v was rewritten too: with the volume
given but the path hidden from conversion inside sh -c "ls /data", the
container still had no /data folder.
The fix
MSYS_NO_PATHCONV=1 docker run --rm -v "$(pwd)/data:/data" postgres:18 ls /data
hello.txt
MSYS_NO_PATHCONV=1 switches the conversion off for that one command, and Docker
Desktop accepts the /c/Users/... form of the host path on its own. To switch it
off for the whole session, export MSYS_NO_PATHCONV=1; leave it unset in your
profile if other tools you run from Git Bash rely on the conversion. A leading double slash
(//data) is often suggested as an alternative; in this test it did not give a
working mount, so the variable is the fix to use.
How it was reproduced
On Windows 11 with Docker Desktop 4.91 (client and engine 29.8.2), from Git Bash 5.2.26 in
Git for Windows 2.45.2, using the cached postgres:18 image only to run
ls and echo. The host folder held one file,
hello.txt. Without the variable, ls failed with exit code 2;
with it, the file was listed.
Frequently asked
- Why does Git Bash add C:/Program Files/Git to my Docker path?
- Git Bash converts arguments that look like absolute Unix paths into Windows paths when it starts a Windows program such as docker.exe. Its root folder is the Git installation, so /data becomes C:/Program Files/Git/data.
- How do I stop Git Bash from converting paths for docker run?
- Put MSYS_NO_PATHCONV=1 in front of the command, or export it for the session. The container then receives the path exactly as you typed it.
- Why is my Docker bind mount empty in Git Bash?
- The mount target after the colon was converted to a Windows path, so the folder was mounted somewhere else. Run the command with MSYS_NO_PATHCONV=1 and the mount lands at the path you gave.
More decoded errors in the Fixes category. Another Docker error that depends on the terminal you run it from: the input device is not a TTY.