Docker Community Forums

Share and learn in the Docker community.

Docker toolbox and windows paths


(Nabil Redmann) #1

So I need help to get this clarified:

Docker toolbox (docker.exe) has issues to with windows paths in the --volume param.

ISSUE -> RESULT

  • colon “:” do not work -> no other drive then C possible
  • spaces “” do not work -> no default windows folders are possible (Program Files, …)
  • backslashes “\” do not work -> no shell/env-variables for paths are possible
  • no relative path gets resolved “./..” -> absolute path wanted

-> Kitematic dies the same death on those Paths.

example:

D:\Github Projects\Testproject 1\>docker.exe -p 8000:80 -v "%cd%\www":/app --name "Test Project1" bananaacid/docker-php7.2-kitematic

resulting in, but not accepted:

docker.exe -p 8000:80 -v "D:\Github Projects\Testproject 1\www":/app --name "Test Project1" bananaacid/docker-php7.2-kitematic


Same issue on cmd.exe as well as powershell.exe.

So --volume is actually not usable on windows? Or is there any workaround vor all these problems?


edit (partial solution: for drive and backslashes, not spaces):
since docker is using cygwin internally, all paths have to be converted to cygwin paths (cygpath). $(pwd) is powershell inserting the current path, executing $(& ...cygpath "..currentpath..") for docker to get a unix path:
tried powershell>docker run -p 8000:80 -p 8443:443 --volume "$(& "C:\Program Files\Git\usr\bin\cygpath.exe" "$(pwd)\www")":/app --name TestProject1 bananaacid/docker-php7.2-kitematic

which does in fact substitute correctly, but the space is still not accepted. A path without a space would work. Result so far: /d/Github Projects/Testproject 1/www/
Manually escaping the space with a backspace, does not work either:
--volume "/d/Github Projects/Testproject 1/www/":/app
--volume "/d/Github\ Projects/Testproject\ 1/www/":/app
--volume /d/Github\ Projects/Testproject\ 1/www/:/app
--volume "/d/Github Projects/Testproject 1/www/:/app"


edit2:
docker-compose does do resolve

volumes:
  - ./..:/app

with COMPOSE_CONVERT_WINDOWS_PATHS=1 in .env

docker inspect shows the mounts with correct path, but VOLUMES is still not being set.

-> no solution yet.


(Ganni) #2

Hi! check this out!
see if this works and let me know.
this just worked for me!
here is the link for my reply on another post here.