發表文章

Windows 連 Synology NAS 建 Git Repo:git 出現 dubious ownership 錯誤

圖片
我在 Windows 用網路位置連上我的 NAS,然後建立了一個 git repo。 正當我要 git commit 的時候,出現了錯誤: Failed to get UnRev file list fatal: detected dubious ownership in repository at '//NAS/_' To add an exception for this directory, call: git config --global --add safe.directory '%(prefix)///NAS/_' Set the environment variable GIT_TEST_DEBUG_UNSAFE_DIRECTORIES=true and run again for more information. 我一開始腦補成「Git 沒有該資料夾權限」之類的(懶得看錯誤訊息 🙈), 後來才發現是 Git 認為該 repo 的擁有者/路徑不安全(dubious ownership)。 解法就是把該路徑加入白名單: git config --global --add safe.directory "%(prefix)///MyNAS/_" 列出所有白名單: git config --get-all safe.directory 白名單會寫入使用者目錄下的 .gitconfig : %USERPROFILE%\.gitconfig .gitconfig 範例如下: [user] name = Peter email = peter@mail.com [safe] directory = %(prefix)///MyNAS/工作日誌 directory = %(prefix)///MyNAS/_ 版本/修改異動 2025-12-19 v1.0 初版 由 ChatGPT 調整 HTML 內文樣式 ...

docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:xxxx: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

圖片
每次新人報到,詭異的事件也會出現。 我新同事表示他把 container 砍了又建立,砍了又建立... (不知道怎麼弄的),然後突然就出現下面這個錯誤:  docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:xxxx: bind: An attempt was made to access a socket in a way forbidden by its access permissions. 我自己環境沒有辦法重現這個錯誤。 然後新同事表示只要重新 docker run -p xxxx:aaaa 使用到 xxxx Port 號,就會出現這個問題。 docker run 執行下去後,container 有被建立,但是 Status 是 Created 不是 Up ,完全就是一個不能動的狀態。 新同事試著重開機、重新啟動 docker 、重新安裝 docker 都無解。 而我也用 netstat - ano 去查看 xxxx 是否被占住了,但是沒有發現任何 xxxx Port 號。 最後是另外一同事在 stackoverflow 找到一篇   Ports are not available: listen tcp 0.0.0.0/50070: bind: An attempt was made to access a socket in a way forbidden by its access permissions net stop winnat docker start ... net start winnat 然後用管理員權限去執行就解決了。 這段主要是先暫時停止 winnat (Windows NAT Driver) ,然後啟動 container ,最後在開啟 winnat 。 哀~又一篇 It works.... ,why? 參考:  Docker error "Ports are not available" on Windows 10 Ports are not available: listen tcp 0.0.0.0/50070: bind: An attempt wa...