ice rabbit programming

[Docker][이슈] Are you trying to mount a directory onto a file (or vice-versa)? check if the specified host path exists and is the expected type. 에러 발생 본문

Development/Infra

[Docker][이슈] Are you trying to mount a directory onto a file (or vice-versa)? check if the specified host path exists and is the expected type. 에러 발생

판교토끼 2021. 5. 7. 21:06

docker run을 할 때 -v 옵션을 주어 volume을 줄 수 있다. 그런데 자꾸 이런 에러가 발생할 때가 있다.

Are you trying to mount a directory onto a file (or vice-versa)? check if the specified host path exists and is the expected type.

근본적으로는 이것은 -v로 넘겨주는 것이 파일이 아니라 디렉토리라 발생하는 에러이다. 아마 이 에러를 검색해서 들어오신 분은 volume으로 넘겨주는 파일명을 잘못(오타를 냈거나 잘못 지정했거나) 적었을 확률이 크다. 만약 넘겨주는 파일명이 존재하지 않으면, 자동으로 mkdir이 된 후에 docker run이 실행되기 때문에.. 엉뚱한 위와 같은 에러가 발생해서 원인을 찾기 더욱 어렵다.

찾아보다가 또다른 원인으로는 파일명과 폴더명이 동일한 경우 가끔 발생할 수 있다고 한다.