티스토리 뷰
구글링해보면 commit해서 이미지 뜬 다음 새로 만들때 -v 옵션을 줘서 마운트를 하라고 시킨다.
하지만 sudo 권한과 docker를 재시작할 수 있는 기회가 있다면 아래와 같이 좀 더 편한 방법을 시도해볼 수 있다.
먼저 /var/lib/docker/containers로 이동해서 수정하고자 하는 컨테이너 ID의 폴더로 들어가자.
그곳에는 config.v2.json이라는 설정 파일이 있는데, 이 내용을 수정하고 docker를 재시작하는 방법이 되겠다.
즉,
systemctl stop docker.service
vim config.v2.json
systemctl start docker.service
어떤 부분을 고치면 되냐면...
"MountPoints":{"<TARGET_DIR>":{"Source":"<SOURCE_DIR>","Destination":"<TARGET_DIR>","RW":true,"Name":"","Driver":"","Type":"bind","Propagation":"rprivate","Spec":{"Type":"bind","Source":"<SOURCE_DIR>","Target":"<TARGET_DIR>"},"SkipMountpointCreation":false}}
예를 들어 /external 폴더를 내 컨테이너 안의 /dataset 폴더로 연결시키고 싶다면 아래와 같이 고치면 된다.
"MountPoints":{"/dataset":{"Source":"/external","Destination":"/dataset","RW":true,"Name":"","Driver":"","Type":"bind","Propagation":"rprivate","Spec":{"Type":"bind","Source":"/external","Target":"/dataset"},"SkipMountpointCreation":false}}
댓글