EACCES Error when building docker image from Dockerfile

System Information
  • Strapi Version:latest
  • Operating System:Win/Alpine Linux
  • Database: Sqlite
  • Node Version: 18
  • NPM Version: 9.6.7
  • Yarn Version: -

When trying to create a docker image from the Dockerfile described here I receive this error. What can I do? I am a new learner so please bear with me.

Error: EACCES: permission denied, rmdir ‘/opt/app/.cache/admin’

docker build -t strapi-test:01 .

[+] Building 238.8s (14/14) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 659B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker./library/node:16-alpine 0.5s
=> [internal] load build context 227.7s
=> => transferring context: 302.32MB 227.4s
=> [ 1/10] FROM docker./library/node:16-alpine@sha256:f1657204d3463bce763cefa5b25e48c28af6fe0cdb0f68b354f0f8225ef61be7 0.0s
=> CACHED [ 2/10] RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev 0.0s
=> CACHED [ 3/10] RUN addgroup -g 1001 strapi && adduser -u 1001 -G strapi -s /bin/sh -D strapi 0.0s
=> CACHED [ 4/10] WORKDIR /opt/ 0.0s
=> CACHED [ 5/10] COPY package.json package-lock.json ./ 0.0s
=> CACHED [ 6/10] RUN npm config set network-timeout 600000 -g && npm install 0.0s
=> CACHED [ 7/10] WORKDIR /opt/app 0.0s
=> CACHED [ 8/10] RUN chown -R strapi:strapi /opt/app 0.0s
=> [ 9/10] COPY . . 6.9s
=> ERROR [10/10] RUN [“npm”, “run”, “build”] 3.5s

[10/10] RUN [“npm”, “run”, “build”]:
#14 0.740
#14 0.740 > bae-po-2@0.1.0 build
#14 0.740 > strapi build
#14 0.740
#14 3.439 Building your admin UI with development configuration…
#14 3.454 [Error: EACCES: permission denied, rmdir ‘/opt/app/.cache/admin’] {
#14 3.454 errno: -13,
#14 3.454 code: ‘EACCES’,
#14 3.454 syscall: ‘rmdir’,
#14 3.454 path: ‘/opt/app/.cache/admin’
#14 3.454 }
#14 3.467 npm notice
#14 3.467 npm notice New major version of npm available! 8.19.4 → 9.6.7
#14 3.467 npm notice Changelog: https://github/npm/cli/releases/tag/v9.6.7
#14 3.467 npm notice Run npm install -g npm@9.6.7 to update!
#14 3.467 npm notice


executor failed running [npm run build]: exit code: 1


In case anyone is interested: I had to remove all USER actions from the Dockerfile to make it work.

RUN chown -R node:node /opt/app
USER node

It had to run with root user.

2 Likes

This fixed my error, FYI i used strapi-community/dockeriz to create my project (included the Dokerfile)