這就是我最初所做的
docker run --name=nodesetup -it --mount type=bind,source="$(pwd)",target=/usr/src/app -w /usr/src/app
node bash
Mysql2 作業正常
npm i mysql2
當我去
npx create-react-app test-client
sh: 1: create-react-app: Permission denied
我系結掛載的 root@83d263a01dc7:/usr/src/app/test-app#。
如何解決這個問題?
uj5u.com熱心網友回復:
這是您映射的主機目錄的權限問題。究竟是什么問題,我想不通。容器以 root 身份運行,因此它應該具有訪問權限。
但是,如果您通過添加-u $(id -u):$(id -g)作為選項在主機上使用用戶的 UID 和 GID 運行容器,則它可以作業。像這樣
docker run --name=nodesetup -it --mount type=bind,source="$(pwd)",target=/usr/src/app -w /usr/src/app -u $(id -u):$(id -g) node bash
這還有一個好處,即在主機上創建的檔案歸您所有,從而更容易編輯它們等。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/469081.html
標籤:javascript 码头工人
