Home > front end >  Dockerfile.dev: nodemon: Permission denied
Dockerfile.dev: nodemon: Permission denied

Time:07-23

Setting up my dev environment on Docker. I am running Nodejs v16.16.0.

I am using Nodemon and a docker volume to keep my dev work in sync with the docker container.

Dockerfile.dev

FROM node:alpine

WORKDIR /usr/src/app

COPY . .

RUN npm install

EXPOSE 3000

CMD ["npm", "run", "dev"]

package.json

{
  "name": "docker-example-1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index",
    "dev": "nodemon index",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "Kane Hooper <[email protected]>",
  "license": "MIT",
  "dependencies": {
    "express": "^4.18.1"
  },
  "devDependencies": {
    "nodemon": "^2.0.19"
  }
}

I execute docker run -p 8080:3000 -v $(pwd):/usr/src/app -v /usr/src/app/node_modules --name nodeappcontainer nodeapp

I get the following error /tmp/dev6585779965.sh: line 2: nodemon: Permission denied

Any assistance on how to resolve this would be much appreciated.

CodePudding user response:

The problem resolved when I bumped the version of nodemon from 2.0.18 down to 2.0.16.

CodePudding user response:

Add the following line before the EXPOSE on your dockerfile, this will grant access for reading and writing on your .sh script

RUN ["chmod", "755","/tmp/dev6585779965.sh"]

  • Related