Permission denied to run npm install in alpine-chrome docker image

I'm trying to create my own docker image on alpin-chrome (86-with-node) to use my nodejs app with puppeteer.

Can anyone tell me why I don't have access to the app directory to install npm packages? With default alpine installing npm packages works like a charm...

I have tried the following dockerfile:

FROM zenika/alpine-chrome:86-with-node

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

# Create app directory
WORKDIR /usr/src/scraper

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm ci --only=production
# If you are building your code for development
# RUN npm install

# Bundle app source
COPY . .


EXPOSE 3040
CMD [ "node", "app.js" ]

But I get the following error:

Step 5/9 : RUN npm ci --only=production
 ---> Running in 06c02bd505ac
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/src/scraper/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/src/scraper/node_modules'
npm ERR!  [OperationalError: EACCES: permission denied, mkdir '/usr/src/scraper/node_modules'] ***
npm ERR!   cause: [Error: EACCES: permission denied, mkdir '/usr/src/scraper/node_modules'] ***
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'mkdir',
npm ERR!     path: '/usr/src/scraper/node_modules'
npm ERR!   ***,
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/src/scraper/node_modules'
npm ERR! ***
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

2 answers