节点容器无法使用docker for windows运行

从docker工具箱切换到docker for windows后,我无法让我的容器运行。 启动容器后,它立即失败,状态为EXIT 254 。 这个设置以前使用virtualbox工作,我很困难的问题可能是什么。 构build成功完成。

这是错误的:

 frontend_1 | npm info it worked if it ends with ok frontend_1 | npm info using npm@3.8.6 frontend_1 | npm info using node@v5.12.0 frontend_1 | npm ERR! Linux 4.4.15-moby frontend_1 | npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev:no-debug" frontend_1 | npm ERR! node v5.12.0 frontend_1 | npm ERR! npm v3.8.6 frontend_1 | npm ERR! path /usr/src/app/package.json frontend_1 | npm ERR! code ENOENT frontend_1 | npm ERR! errno -2 frontend_1 | npm ERR! syscall open frontend_1 | frontend_1 | npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json' frontend_1 | npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json' frontend_1 | npm ERR! enoent This is most likely not a problem with npm itself frontend_1 | npm ERR! enoent and is related to npm not being able to find a file. frontend_1 | npm ERR! enoent frontend_1 | frontend_1 | npm ERR! Please include the following file with any support request: frontend_1 | npm ERR! /usr/src/app/npm-debug.log 

这是我的Dockerfile:

 FROM node:5 WORKDIR /usr/src/app COPY package.json /usr/src/app/ RUN npm install COPY . /usr/src/app/ CMD [ "npm", "run", "dev:no-debug" ] 

这是相关的撰写文件设置:

 services: frontend: build: context: ./frontend volumes: - ./frontend:/usr/src/app - /usr/src/app/node_modules expose: - "7777" environment: - "PORT=7777" - "VIRTUAL_PORT=7777" - "VIRTUAL_HOST=test.example.com" 

编辑:添加目录结构:

 C └---Users |----deepc |----docker |----myproject |---nginx |---dockergen |---frontend ---package.json, node_modules, src, Dockerfile ---docker-compose.yml 

在你compose.yml你挂载这个卷:

 - ./frontend:/usr/src/app 

所以基本上你以前在dockerfile中做的是无用的。

如果您的frontend文件夹中没有package.json,那就是问题所在

我认为这是很难在这样的距离debugging,但你可以尝试build立这样的容器,看看它是否工作?

 FROM node:5 RUN mkdir -p /usr/src/app COPY . /usr/src/app WORKDIR /usr/src/app RUN npm install CMD ["npm", "run", "dev:no-debug"] 

我相信这个问题是与:

没有这样的文件或目录,打开“/usr/src/app/package.json”

…它告诉我,你期望存在的目录,不! 不完全确定是否需要在复制之前创build目录,但是如果您可以将构build日志的输出提供给我们,这将有所帮助。