dockercompose up build fail (node no such file or directory packages.json )

docker构建项目遇到如下问题:


npm ERR! Darwin 15.0.0 npm ERR! argv "/usr/local/lib/node_modules/iojs-bin/node_modules/iojs-darwin-x64/iojs-v3.3.0-darwin-x64/bin/iojs" "/usr/local/bin/npm" "i" npm ERR! node v3.3.0 npm ERR! npm v3.3.3 npm ERR! path /Users/aredridel/Projects/npm/newww/node_modules/hapi/node_modules/inert/node_modules/lru-cache npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall rename npm ERR! enoent ENOENT:
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/lib/node_modules/iojs-bin/node_modules/iojs-darwin-x64/iojs-v3.3.0-darwin-x64/bin/iojs" "/usr/local/bin/npm" "i"
npm ERR! node v3.3.0
npm ERR! npm  v3.3.3
npm ERR! path /Users/aredridel/Projects/npm/newww/node_modules/hapi/node_modules/inert/node_modules/lru-cache
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename '/Users/aredridel/Projects/npm/newww/node_modules/hapi/node_modules/inert/node_modules/lru-cache' -> '/Users/aredridel/Projects/npm/newww/node_modules/inert/node_modules/lru-cache'
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!     /Users/aredridel/Projects/npm/newww/npm-debug.log
, rename '/Users/aredridel/Projects/npm/newww/node_modules/hapi/node_modules/inert/node_modules/lru-cache' -> '/Users/aredridel/Projects/npm/newww/node_modules/inert/node_modules/lru-cache' 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! /Users/aredridel/Projects/npm/newww/npm-debug.log


solve method: the path fo source not mount volumes correctly . use kitematice and select the right path
这里的找不到packages.json 和找不到代码路径有关,主要问题在于kitematic 的版本可能无法识别 docker的compose 文件中mount路径,需要手动挂载项目路径到 volumns 下

挂载到目录后遇到 找不到express 的错误,
 

此时,kitematic 管理器中可以使用exec 控制台,进入路径后执行 npm install  --save 

other question: windows  上docker 默认 default ip 192.168.99.100,如何修改ip:

 a current workaround, assuming you've got the Toolbox installed:

Close Kitematic
Delete the current default VM: docker-machine rm -f default
Create a new default machine docker-machine create -d virtualbox --virtualbox-hostonly-cidr "192.168.99.1/24"
Open Kitematic and it should be using this VM.

 
这个方案是先停掉kitematic,然后用docker-machine删除默认的vm实例,重新创建一个vm,指定ip,然后启动kitematic,刚创建的就可以自动识别了 



原文地址:https://www.cnblogs.com/lavin/p/6852230.html