WSL,bash,Docker:"unable to prepare context"

WSL, bash, Docker: "unable to prepare context"

在使用 WSL 和 bash 关注 this tutorial 时,我得到:

~$ cd /tmp/docker-nginx-test

/tmp/docker-nginx-test$ ls -la
total 0
drwxrwxrwx 0 george george 4096 Apr 21 06:27 .
drwxrwxrwt 0 root   root   4096 Apr 21 06:02 ..
-rw-rw-rw- 1 george george   18 Apr 21 06:27 Dockerfile

/tmp/docker-nginx-test$ docker.exe build /tmp/docker-nginx-test
unable to prepare context: path "/tmp/docker-nginx-test" not found

还有:

/tmp/docker-nginx-test$ docker.exe build  ./Dockerfile
unable to prepare context: path "./Dockerfile" not found
/tmp/docker-nginx-test$ ls -al ./Dockerfile
-rwxrwxrwx 1 george george 18 Apr 21 06:27 ./Dockerfile

与:

$ docker.exe --version
Docker version 18.03.0-ce, build 0520e24

对于上述教程,使用 WSL 和 bash 的成功方法是:

$ mkdir docker-nginx-test
$ cd docker-nginx-test
$ docker-compose.exe down
$ docker-compose.exe build --pull --no-cache
$ docker-compose.exe -f docker-compose.yml up -d --remove-orphans

我发现问题是我只使用了 Linux 路径 (/home/user/project/Dockerfile) 但我不得不使用我的 WSL 发行版所在的 Windows 文件路径存储,然后取 rootfs 下的路径并转义反斜杠。像这样:

docker.exe build -t 
C:\Users\username\Ubuntu1804WSL\CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2018.817.0_x64__79rhkp1fndgsc\rootfs\home\user\scratch\project

帮我修好了。