无法在C盘上装载文件夹作为卷

时间:2016-10-30 05:13:19

标签: docker

我在我的用户目录中创建了一个示例快速站点,并将其安装到Docker容器中并且可以正常运行。请参阅下面的输出:

xxxxx@DESKTOP-PCAAQU0 MINGW64 ~/ExpressSite
$ docker run -p 8080:3000 -v $(pwd):/var/www1 -w "/var/www1" node npm start
npm info it worked if it ends with ok
npm info using npm@3.10.8
npm info using node@v7.0.0
npm info lifecycle ExpressSite@0.0.0~prestart: ExpressSite@0.0.0
npm info lifecycle ExpressSite@0.0.0~start: ExpressSite@0.0.0

> ExpressSite@0.0.0 start /var/www1
> node ./bin/www

如果我在C盘上名为dockertest的文件夹中复制/粘贴同一目录,则会出现以下错误:

xxxxx@DESKTOP-PCAAQU0 MINGW64 /c/dockertest/ExpressSite
$ docker run -p 8080:3000 -v $(pwd):/var/www1 -w "/var/www1" node npm start
npm info it worked if it ends with ok
npm info using npm@3.10.8
npm info using node@v7.0.0
npm ERR! Linux 4.4.27-boot2docker
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.0.0
npm ERR! npm  v3.10.8
npm ERR! path /var/www1/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/var/www1/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/var/www1/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www1/npm-debug.log

我在这里错过了什么吗?

xxxxx@DESKTOP-PCAAQU0 MINGW64 /c/dockertest/ExpressSite
$ ls
app.js  bin/  node_modules/  package.json  public/  routes/  views/

1 个答案:

答案 0 :(得分:2)

确保您使用Docker for Windows(需要64位Windows 10专业版,企业版和教育版(1511年11月更新版,Build 10586版或更高版本)和Microsoft Hyper-V版),而不是旧版Docker Toolbox(它使用Oracle Virtual Box而不是Hyper-V。)

https://cloud.githubusercontent.com/assets/7180398/18270828/3b385b82-742f-11e6-8c74-eb55d73b0b0a.png

  

我使用任务栏中的小鲸鱼图标转到设置/共享驱动器屏幕   我检查了C驱动器,然后点击了Apply。它让我输入我的Windows凭据   此更改后,我从“设置”菜单重置了docker。

有关详情,请参阅issue 18756 例如,这个comment mentions

  

对于mingw bash shell,这就是docker工具箱添加(例如在bashrc中)以阻止mingw破坏路径:

docker () {
  MSYS_NO_PATHCONV=1 docker.exe "$@"
}
export -f docker

当与Docker for Windows一起使用时,bash会话的bashrc中可能没有这个。