Docker-Compose up命令出现“找不到目录”错误

时间:2020-05-22 07:37:24

标签: docker docker-compose

我正在使用Windows 10家庭版(正在运行VirtualBox,这可能是我的问题。我在VirtualBox中有一个共享文件夹,设置为c:/ Courses / Containerization / frontend,可以使用此文件夹。当我使用时使用“ docker” PATH的相关依赖项,一切正常,但是当我使用docker-compose时似乎无法避免错误。关于为什么的任何想法?

文件夹结构:

$ ls
build/  docker-compose.yaml  Dockerfile.dev  package.json  public/  README.md  src/

Dockerfile.dev文件:

FROM node:alpine

WORKDIR '/app'

COPY package.json .
RUN ls -al
RUN npm install

COPY . .

CMD ["npm", "run", "start"]

docker-compose.yaml文件:

version: '3.7'
services:
  web:
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - '3000:3000'
    volumes:
      - /app/node_modules
      - .:/app
    environment:
      - CHOKIDAR_USEPOLLING=true
  tests:
    build:
      context: .
      dockerfile: Dockerfile.dev
    volumes:
      - /app/node_modules
      - .:/app
    environment:
      - CHOKIDAR_USEPOLLING=true
    command: ['npm', 'run', 'test']

错误:

tests_1  | npm ERR! code ENOENT
tests_1  | npm ERR! syscall open
tests_1  | npm ERR! path /app/package.json
tests_1  | npm ERR! errno -2
tests_1  | npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
tests_1  | npm ERR! enoent This is related to npm not being able to find a file.
tests_1  | npm ERR! enoent
tests_1  |
tests_1  | npm ERR! A complete log of this run can be found in:
web_1    | npm ERR! code ENOENT
web_1    | npm ERR! syscall open
web_1    | npm ERR! path /app/package.json
web_1    | npm ERR! errno -2
web_1    | npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
web_1    | npm ERR! enoent This is related to npm not being able to find a file.
web_1    | npm ERR! enoent
web_1    |
web_1    | npm ERR! A complete log of this run can be found in:
tests_1  | npm ERR!     /root/.npm/_logs/2020-05-22T07_34_11_270Z-debug.log
frontend_tests_1 exited with code 254
web_1    | npm ERR!     /root/.npm/_logs/2020-05-22T07_34_11_338Z-debug.log
frontend_web_1 exited with code 254

0 个答案:

没有答案