1

I ran the following command in MacOS to mount the current directory to container's src directory. How would I do this in windows 10.

docker run -it --rm --mount type=bind,source="$(pwd)",target=/src ucd-fff-connector bash -c 'cd src; python main.py;'

For example, I know I have to change "$(pwd)" to "%cd%". I do not have a windows computer to test. Do I also need to switch single quote ' to double quote "?

It would be also nice to have a version to run across different platforms, ie: command prompt, terminal, powershell and etc

leogoesger
  • 3,476
  • 5
  • 33
  • 71

2 Answers2

1

Mounts current folder in windows (PowerShell):

docker run --rm --workdir /code -v "$(get-location):/code" "trzeci/emscripten:sdk-tag-1.38.32-64bit" ls

Which is equivalent to linux/mac:

docker run --rm --workdir /code -v "$PWD":/code "trzeci/emscripten:sdk-tag-1.38.32-64bit" ls
cancerbero
  • 6,799
  • 1
  • 32
  • 24
-2

You may not need to worry about that as of right now since Docker does not support with native Windows OS.

In order to install Docker on Windows, you'll need to install the Docker toolbox which uses VirtualBox to spin up a VM that acts as a docker machine and the toolbox will present you with Unix terminal on launch that kind of make it bit easy as it's able to translate almost all Linux commands to Windows.

Prav
  • 2,785
  • 1
  • 21
  • 30
  • windows 10 is being supported by Docker. All that has been working and tested on a windows computer just now! It is just the syntax difference that I am worrying about – leogoesger Jun 22 '18 at 21:26
  • 1
    Ok, my bad I see they have now released a Windows compatible Docker as well. So this depends on which version of the Docker you've installed. My answer only applies if you've installed Docker Toolbox for Windows. If you've installed Docker for Windows then you need to use commands that are compatible with the respected command line (Powershell/Command Prompt). – Prav Jun 22 '18 at 21:32
  • `winpty docker run -it --rm --mount type=bind,source="%cd%",target=/src ucd-fff-connector bash -c "cd src; python main.py;"` worked. Double quote is needed. `%cd%` is needed and also prefix with `winpty` is needed for interactive shell. – leogoesger Jun 22 '18 at 21:38