// docker-compose.yaml
volumes:
- .:/usr/src/app # 정리한 문서의 data 유지 방법 중 두 번째 경우에 해당 ... (1)
- - "/usr/src/app/node_modules" # 정리한 문서의 data 유지 방법 중 첫 번째 경우에 해당 ... (2)
- - "/usr/src/app/.next" # 정리한 문서의 data 유지 방법 중 첫 번째 경우에 해당 ... (3)
(1)은 bind mount의 경우로 docker-compose up -d 명령어를 실행하는 디렉토리의 하위 파일들이 변경이 되었을 때, 컨테이너의 /usr/src/app에도 똑같이 반영됨(반대의 경우에도 마찬가지). 즉, 컨테이너의 /usr/src/app는 현재 작업중인 디렉토리를 바라보게 됨(or mapping 된다고 표현함)
(2)와 (3)은 호스트 머신의 특정 volume을 지정하지 않은 경우로 호스트 머신의 /var/lib/docker/volumes 경로에 도커가 자동 생성한 해쉬 디렉토리를 바라보게 됨(or mapping 됨)
예를 들어, 기존의 경우(즉, (2)와 (3)이 제거되지 않고 그대로 적용되어 있는 경우)에 컨테이너의 /usr/src/app/node_modules는 호스트 머신의 ./node_modules를 바라보고 있지 않고 /var/lib/docker/volumes/qasd1klhvzix189aghv를 바라보고 있으므로 npm install classnames 명령어를 실행했을 때, 호스트 머신의 ./node_modules 에는 classnames 패키지가 설치되었지만, /var/lib/docker/volumes/qasd1klhvzix189aghv에는 classnames가 설치되지 않았으므로 "classnames 패키지가 존재하지 않습니다"라는 에러가 발생함
이슈
58
설명
docker-compose up -d
명령어를 실행하는 디렉토리의 하위 파일들이 변경이 되었을 때, 컨테이너의/usr/src/app
에도 똑같이 반영됨(반대의 경우에도 마찬가지). 즉, 컨테이너의/usr/src/app
는 현재 작업중인 디렉토리를 바라보게 됨(or mapping 된다고 표현함)/var/lib/docker/volumes
경로에 도커가 자동 생성한 해쉬 디렉토리를 바라보게 됨(or mapping 됨)/usr/src/app/node_modules
는 호스트 머신의./node_modules
를 바라보고 있지 않고/var/lib/docker/volumes/qasd1klhvzix189aghv
를 바라보고 있으므로npm install classnames
명령어를 실행했을 때, 호스트 머신의./node_modules
에는 classnames 패키지가 설치되었지만,/var/lib/docker/volumes/qasd1klhvzix189aghv
에는 classnames가 설치되지 않았으므로 "classnames 패키지가 존재하지 않습니다"라는 에러가 발생함