簡體   English   中英

Docker 容器上的 Nodemon 獲得“權限被拒絕”

[英]Nodemon on Docker container gets “Permission denied”

我在使用 Nodemon 的 Docker 容器內有一個 Node.js 服務器。 在我的 Windows 10 機器上,一切正常,但是當我嘗試在 Ubuntu 上使用 docker-compose 安裝它時,我收到以下錯誤:

/usr/local/bin/docker-entrypoint.sh: exec: line 8: /usr/src/app/node_modules/.bin/nodemon: Permission denied

我發現 Nodemon 有時會這樣做,解決方案是使用 sudo 全局安裝它。 I have done that and I've also tried running an npm install of Nodemon before copying package.json in the Dockerfile but it didn't work. 此外,該位置似乎沒有任何 docker-entrypoint.sh 。

這是我的 Dockerfile:

FROM node:10.16-alpine

RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app
COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8080

CMD ["npm","start"]

您缺少二進制文件的可執行權限。 您可以在 Dockerfile 的末尾添加以下內容:

chmod +x /usr/src/app/node_modules/.bin/nodemon

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM