所以我正在阅读 docker 教程,并在我的 power shell 中执行了这个:
docker run -dp 3000:3000 `
-w /app -v "$(pwd):/app" `
node:12-alpine `
sh -c "yarn install && yarn run dev"
但是我的容器在运行后立即退出。所以在观察日志后,这似乎是问题所在:
yarn install v1.22.5
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error Could not write file "/app/yarn-error.log": "EPERM: operation not permitted, open
'/app/yarn-error.log'"
error An unexpected error occurred: "EPERM: operation not permitted, mkdir '/app/node_modules'".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
我在管理员模式下运行 PowerShell,没有项目文件是只读的,并且在文件夹属性中,用户和管理员拥有完全控制权。那么为什么会出现这个问题呢?
最佳答案
我通过更改文件夹权限访问/app/来修复它。
它只允许我进行更改,所以我将其更改为允许访问写入执行和读取到所有人并且它工作正常。
因此,更改文件夹的正确访问权限应该可以解决您的问题。
关于docker - EPERM : operation not permitted, 在 Windows 中打开 '/app/yarn-error.log',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65058108/