关于使用docker-compose安装nodejs开发环境遇到的一个问题

我新建了一个dockerfile内容如下

FROM node:latest
RUN mkdir -p /mnt/app
# Create app directory
WORKDIR /mnt/app

# Install app dependencies
COPY package.json /mnt/app
RUN npm install

# Bundle app source
COPY  . /mnt/app

EXPOSE 3000
CMD [ "npm", "start" ]

docker-compose文件内容如下

node:
        build:
            context: ./services/node/website
            dockerfile: Dockerfile
        ports:
          - "3000:3000"
        #volumes:
        #  - ./app:/mnt/app

文件结构是
clipboard.png

问题现在是不使用docker-compose数据映射,单纯使用dockerfile copy方法进去就可以跑起来node,但如果我使用数据映射

volumes:
  - ./app:/mnt/app

则就报错

报错信息如下:

npm info it worked if it ends with ok
npm info using npm@5.4.2
npm info using node@v8.7.0
npm ERR! path /mnt/app/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/mnt/app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2017-10-20T03_08_13_487Z-debug.log

求大神看下

回复
阅读 4.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏