Hello there,
sir, I am stuck on a topic. when I add the user in Dockerfile at the end and building an image from it and after that when I start a container from this image by using the following command
docker run react-app npm start
it gives the permission denied error.
because you an I created build as a root user and defined the new app user at the end. when I following you moved the new user at the top then the permission denied error becomes while building the image. kindly help to resolve this problem. the content of Dockerfile before and after is attaching with this post
Before
FROM node:14.16.1-alpine3.13
WORKDIR /app/
COPY package*.json .
RUN npm install
COPY . .
ENV API_URL=https://api.myapp.com
EXPOSE 3000
RUN addgroup app && adduser -S -G app app
USER app
creating image from it
docker build -t react-app
error after running the command ādocker run react-app npm startā
"
ļ½¢wdsļ½£: Project is running at http://172.17.0.2/
ļ½¢wdsļ½£: webpack output is served from
ļ½¢wdsļ½£: Content not from webpack is served from /app/public
ļ½¢wdsļ½£: 404s will fallback to /
Starting the development serverā¦
Failed to compile.
EACCES: permission denied, mkdir ā/app/node_modules/.cacheā
"
After
Dockerfile
FROM node:14.16.1-alpine3.13
RUN addgroup app && adduser -S -G app app
USER app
WORKDIR /app/
COPY package*.json .
RUN npm install
COPY . .
ENV API_URL=https://api.myapp.com
EXPOSE 3000
error while building the image after running command ādocker build -t react-appā
"
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access ā/appā
npm ERR! [Error: EACCES: permission denied, access ā/appā] {
npm ERR! errno: -13,
npm ERR! code: āEACCESā,
npm ERR! syscall: āaccessā,
npm ERR! path: ā/appā
npm ERR! }
"