Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 

Docker container 내에서 빌드 시 error MSB3021: Unable to copy file "..." to "...". Access to the path '...' is denied.

docker container에 윈도우 파일 시스템의 디렉터리를 볼륨으로 연결한 다음,

c:\temp> docker run -v C:\temp\TestApp\:/app --name test-instance --rm -it net_build /bin/bash -c "cd /app/TestApp && dotnet build" 

그곳에서 빌드를 했더니 권한 오류가 발생합니다. 혹시나 해서 "docker run -it ..."로 실행해 직접 그 인스턴스에 들어가 빌드를 해도 역시나 오류가 발생합니다.

# whoami
root

# dotnet build
  Determining projects to restore...
  Restored /app/TestApp/TestApp.csproj (in 705 ms).
/usr/share/dotnet/sdk/8.0.404/Microsoft.Common.CurrentVersion.targets(5034,5): error MSB3021: Unable to copy file "/app/Libs/net6.0/Debug/Microsoft.Diagnostics.Runtime.dll" to "bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll". Access to the path '/app/TestApp/bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll' is denied. [/app/TestApp/TestApp.csproj]

Build FAILED.

/usr/share/dotnet/sdk/8.0.404/Microsoft.Common.CurrentVersion.targets(5034,5): error MSB3021: Unable to copy file "/app/Libs/net6.0/Debug/Microsoft.Diagnostics.Runtime.dll" to "bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll". Access to the path '/app/TestApp/bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll' is denied. [/app/TestApp/TestApp.csproj]
    0 Warning(s)
    1 Error(s)

그러니까, 다음의 파일 복사가 안 된다는 것인데요,

"/app/Libs/net6.0/Debug/Microsoft.Diagnostics.Runtime.dll" ==> "bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll"

복사 대상이 되는 파일의 경로가 상대 경로로 나오지만, 그다음 메시지에 나온 것처럼 절대 경로는 '/app/TestApp/bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll'이 됩니다.

'/app/TestApp/bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll'
             "bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll"

그런데, 그냥 저 파일을 삭제하면 아무런 문제 없이 잘됩니다.

# rm '/app/TestApp/bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll'
# rm '/app/TestApp/bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll'
rm: cannot remove '/app/TestApp/bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll': No such file or directory

가만 보니, 권한 오류는 발생하지만 대상 파일이 생성은 되면서 그 크기가 0이라는 점이 재미있습니다.

# dotnet clean

# dotnet build

# ls /app/Libs/net6.0/Debug/Microsoft.Diagnostics.Runtime.dll -l
-r-xr-xr-x 1 root root 861696 Dec 11 02:56 /app/Libs/net6.0/Debug/Microsoft.Diagnostics.Runtime.dll

# ls /app/TestApp/bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll -l
-r-xr-xr-x 1 root root 0 Dec 12 02:24 /app/TestApp/bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll

그러니까, 파일 생성까지는 했는데 쓰는 동안 어떤 식으로든 문제가 생겼다는 것인데요, 더욱 재미있는 건 그냥 cp 명령어를 내리면 또 잘됩니다. ^^;

# cp /app/Libs/net6.0/Debug/Microsoft.Diagnostics.Runtime.dll /app/TestApp/bin/Debug/net8.0/Microsoft.Diagnostics.Runtime.dll

이거저거 살펴본 끝에, 볼륨 매핑을 한 윈도우 측의 디렉터리 권한이 "Administrator"만 읽기/쓰기가 가능하고 "Users" 권한으로는 읽기만 가능한 걸로 나오는데요, 실제로 권한 변경을 했더니,

C:\temp\TestApp> icacls . /grant Users:F /t

이후로는 문제없이 잘 빌드가 됩니다. 신기하군요. ^^; cp는 되고 dotnet build는 안 된다는 것이.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 12/13/2024]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  [2]  3  4  5  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13859정성태1/9/20251850디버깅 기술: 215. Windbg - syscall 이후 실행되는 KiSystemCall64 함수 및 SSDT 디버깅
13858정성태1/8/20251877개발 환경 구성: 738. PowerShell - 원격 호출 시 "powershell.exe"가 아닌 "pwsh.exe" 환경으로 명령어를 실행하는 방법
13857정성태1/7/20251899C/C++: 187. Golang - 콘솔 응용 프로그램을 Linux 데몬 서비스를 지원하도록 변경파일 다운로드1
13856정성태1/6/20251916디버깅 기술: 214. Windbg - syscall 단계까지의 Win32 API 호출 (예: Sleep)
13855정성태12/28/20242211오류 유형: 941. Golang - os.StartProcess() 사용 시 오류 정리
13854정성태12/27/20242554C/C++: 186. Golang - 콘솔 응용 프로그램을 NT 서비스를 지원하도록 변경파일 다운로드1
13853정성태12/26/20242429디버깅 기술: 213. Windbg - swapgs 명령어와 (Ring 0 커널 모드의) FS, GS Segment 레지스터
13852정성태12/25/20242333디버깅 기술: 212. Windbg - (Ring 3 사용자 모드의) FS, GS Segment 레지스터파일 다운로드1
13851정성태12/23/20242282디버깅 기술: 211. Windbg - 커널 모드 디버깅 상태에서 사용자 프로그램을 디버깅하는 방법
13850정성태12/23/20242330오류 유형: 940. "Application Information" 서비스를 중지한 경우, "This file does not have an app associated with it for performing this action."
13849정성태12/20/20242515디버깅 기술: 210. Windbg - 논리(가상) 주소를 Segmentation을 거쳐 선형 주소로 변경
13848정성태12/18/20242507디버깅 기술: 209. Windbg로 알아보는 Prototype PTE파일 다운로드2
13847정성태12/18/20242610오류 유형: 939. golang - 빌드 시 "unknown directive: toolchain" 오류 빌드 시 이런 오류가 발생한다면?
13846정성태12/17/20242615디버깅 기술: 208. Windbg로 알아보는 Trans/Soft PTE와 2가지 Page Fault 유형파일 다운로드1
13845정성태12/16/20242902디버깅 기술: 207. Windbg로 알아보는 PTE (_MMPTE)
13844정성태12/14/20242676디버깅 기술: 206. Windbg로 알아보는 PFN (_MMPFN)파일 다운로드1
13843정성태12/13/20242641오류 유형: 938. Docker container 내에서 빌드 시 error MSB3021: Unable to copy file "..." to "...". Access to the path '...' is denied.
13842정성태12/12/20243031디버깅 기술: 205. Windbg - KPCR, KPRCB
13841정성태12/11/20243117오류 유형: 937. error MSB4044: The "ValidateValidArchitecture" task was not given a value for the required parameter "RemoteTarget"
13840정성태12/11/20242946오류 유형: 936. msbuild - Your project file doesn't list 'win' as a "RuntimeIdentifier"
13839정성태12/11/20242900오류 유형: 936. msbuild - error CS1617: Invalid option '12.0' for /langversion. Use '/langversion:?' to list supported values.
13838정성태12/4/20242901오류 유형: 935. Windbg - Breakpoint 0's offset expression evaluation failed.
13837정성태12/3/20243047디버깅 기술: 204. Windbg - 윈도우 핸들 테이블 (3) - Windows 10 이상인 경우
13836정성태12/3/20243204디버깅 기술: 203. Windbg - x64 가상 주소를 물리 주소로 변환 (페이지 크기가 2MB인 경우)
13835정성태12/2/20243109오류 유형: 934. Azure - rm: cannot remove '...': Directory not empty
13834정성태11/29/20243112Windows: 275. C# - CUI 애플리케이션과 Console 윈도우 (Windows 10 미만의 Classic Console 모드인 경우) [1]파일 다운로드1
1  [2]  3  4  5  6  7  8  9  10  11  12  13  14  15  ...