나는 도커를 처음 사용하며 사용자 정의 이미지를 만들었습니다. 여기내 로컬 소스 파일을 도커 컨테이너에 마운트하는 방법은 무엇입니까?
는 이미지가 구축 된 후 그때
docker build -t test/node .
로 이미지를 구축 내 Dockerfile
FROM node:latest
MAINTAINER FF
COPY . /var/www
WORKDIR /var/www
RUN npm install
EXPOSE 3000
ENTRYPOINT ["npm", "start"]
있습니다 나는 싶어서 -v 사용
docker run -p 8888:3000 -v $(pwd):/var/www -w "/var/www" test/node
를 실행 내 호스트 src 폴더를 /var/www
에 마운트하십시오.
> [email protected] start /var/www
> node ./bin/www
module.js:472
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/www/app.js:1:77)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
npm info lifecycle [email protected]~start: Failed to exec start script
npm ERR! Linux 4.4.39-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.4.0
npm ERR! npm v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the expresssite package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs expresssite
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls expresssite
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! Please include the following file with any support request:
npm ERR! /var/www/npm-debug.log
로 돌아와서 나는 내가 필요로하는 모든입니다 생각했다.
내가 뭘 잘못 했니? 아무도 그것에 대해 나를 도울 수 있습니까? 정말 고마워!
'복사'는 논리적이지 않습니다./ var/www'와'docker run'에서'-v $ (pwd) :/var/www' 명령을 사용하면 COPY가 지운 내용을 지울 수 있습니다. – user2915097