I’m running Docker Desktop 4.19.0 under Windows 10.
There is a container running and I can exec a command on it with docker exec from git-bash, cmd and Ubuntu-on-WSL2.
#git-bash
me@machine MINGW64 ~
$ docker exec 3eef5ce3f69d pwd
/
#cmd
C:\Users\me>docker exec 3eef5ce3f69d pwd
/
#ubuntu
frank@machine:~$ docker exec 3eef5ce3f69d pwd
/
so far, so good. The problem arises when I want to change the WORKDIR.
While that works on cmd and ubuntu, it fails when run from git-bash. But why?
#git-bash
me@machine MINGW64 ~
$ docker exec --workdir=/tmp 3eef5ce3f69d pwd
OCI runtime exec failed: exec failed: Cwd must be an absolute path: unknown
#cmd
C:\Users\me>docker exec --workdir=/tmp 3eef5ce3f69d pwd
/tmp
#ubuntu
frank@machine:~$ docker exec --workdir=/tmp 3eef5ce3f69d pwd
/tmp
>Solution :
Git bash does some non-standard stuff with path expansion to make things like /bin/sh map back to the Git bash installation directory. To disable that behavior, use a leading double slash (//path/to/file):
docker exec --workdir=//tmp 3eef5ce3f69d pwd