Reputation: 61
I try to containerize the react application, but this error persists.
Here's the log:
[+] Building 0.0s (0/0) docker:default
[+] Building 4.2s (9/16) docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 380B 0.0s
=> [internal] load metadata for docker.io/library/nginx:stable-perl 4.0s
=> [internal] load metadata for docker.io/library/node:lts-alpine 4.0s
=> [auth] library/nginx:pull token for registry-1.docker.io 0.0s
=> [auth] library/node:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 52B 0.0s
=> CANCELED [build 1/7] FROM docker.io/library/node:lts-alpine@sha256:a7b980c958bfe4d84ee9263badd95a40c8bb50ad5afdb87902c187fefaef0e24 0.1s
=> => resolve docker.io/library/node:lts-alpine@sha256:a7b980c958bfe4d84ee9263badd95a40c8bb50ad5afdb87902c187fefaef0e24 0.0s
=> => sha256:a7b980c958bfe4d84ee9263badd95a40c8bb50ad5afdb87902c187fefaef0e24 1.43kB / 1.43kB 0.0s
=> => sha256:db4b1d98b5a92263f2b9221c4d7930ce6b02f9834926c8b6174bfed2913cea16 1.16kB / 1.16kB 0.0s
=> => sha256:5414852b0111feebb3686ec58f92f2edb534cef2826b575581cdcadd42a7f527 7.21kB / 7.21kB 0.0s
=> ERROR [internal] load build context 0.1s
=> => transferring context: 1.43MB 0.0s
=> CANCELED [stage-1 1/2] FROM docker.io/library/nginx:stable-perl@sha256:3083ef7ca8bc4f7dc24596382092ae5e53d1169a6e706b83c2b448d044919ba3 0.1s
=> => resolve docker.io/library/nginx:stable-perl@sha256:3083ef7ca8bc4f7dc24596382092ae5e53d1169a6e706b83c2b448d044919ba3 0.0s
=> => sha256:3083ef7ca8bc4f7dc24596382092ae5e53d1169a6e706b83c2b448d044919ba3 10.27kB / 10.27kB 0.0s
=> => sha256:15585364514a1e9df46ec8d6ddfd1a56ee316724f47cb7b375ce4d4df137c856 2.49kB / 2.49kB 0.0s
=> => sha256:e790832271e7c18bce18208197ed61dde7dd4821af50789ceb4bc2c5d1b0b205 9.97kB / 9.97kB 0.0s
------
> [internal] load build context:
------
ERROR: failed to solve: archive/tar: unknown file mode ?rwxr-xr-x
I looked it up; it seems to have something to do with the file permissions. I tried changing the files in the directory via Windows Explorer, but nothing happens.
I have tried the chmod but still no luck.
Here is the Dockerfile
FROM node:lts-alpine AS build
WORKDIR /optimal/
COPY package*.json ./
RUN npm install
COPY src/ /optimal/src
COPY public/ /optimal/public
RUN chmod -R 755 /optimal/src /optimal/public
RUN npm run build
CMD [ "npm", "start" ]
FROM nginx:stable-perl
WORKDIR /usr/share/nginx/html
COPY --from=build /optimal/build /usr/share/nginx/html
EXPOSE 80
CMD [ "nginx", "-g", "daemon off;" ]
Upvotes: 6
Views: 9511
Reputation: 675
Probably you have a file in your build directory which was created by previous docker container runs (through mounted volumes). Erase those files before rebuilding the image.
Upvotes: 1
Reputation: 26
My problem was I had files with .sock extension that created uwsgi. Just delete it.
Upvotes: 1
Reputation: 11
I also deleted the node_modules folder and the package-lock.json file. I didn't even reinstall them, but after running the build it ran with no errors. I found that the build installed both of those on its own.
Upvotes: 1
Reputation: 171
One of the files that the docker copies to the container has its permissions messed up. My guess is that it's something in the node_modules folder with npm.
If you delete the whole node_modules folder and the package-lock.json you can recreate these again with npm install
and npm run build
after which they should have the correct permissions. Then the docker build command should work as expected.
Upvotes: 9