-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error occurs on first run if NPM is not allready installed #10
Comments
Same issue when run cmd in powershell. Logs of **docker build -t welcome-to-docker . **docker build -t welcome-to-docker .
2024/03/01 14:11:12 http2: server: error reading preface from client //./pipe/docker_engine: file has already been closed
[+] Building 3.3s (11/11) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 669B 0.0s
=> [internal] load metadata for docker.io/library/node:18-alpine 3.0s
=> [auth] library/node:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 52B 0.0s
=> [1/6] FROM docker.io/library/node:18-alpine@sha256:ca9f6cb0466f9638e59e0c249d335a07c867cd50c429b5c7830dda1bed584649 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 393B 0.0s
=> CACHED [2/6] WORKDIR /app 0.0s
=> CACHED [3/6] COPY package*.json ./ 0.0s
=> CACHED [4/6] COPY ./src ./src 0.0s
=> CACHED [5/6] COPY ./public ./public 0.0s
=> ERROR [6/6] RUN npm install && npm install -g serve && npm run build && rm -fr node_modules 0.3s
------
> [6/6] RUN npm install && npm install -g serve && npm run build && rm -fr node_modules:
0.253 exec /bin/sh: exec format error
------
Dockerfile:15
--------------------
14 | # Install node packages, install serve, build the app, and remove dependencies at the end
15 | >>> RUN npm install \
16 | >>> && npm install -g serve \
17 | >>> && npm run build \
18 | >>> && rm -fr node_modules
19 |
--------------------
ERROR: failed to solve: process "/bin/sh -c npm install && npm install -g serve && npm run build && rm -fr node_modules" did not complete successfully: exit code: 1
View build details: docker-desktop://dashboard/build/default/default/36fq292mclyizqosxrq2xj1lr
|
I faced the same issue under Windows. Using the same tutorial. Solution: Start cmd as administrator and it would work. If Linux, then Terminal requires |
Yeah - I still can't get it running as well... docker build -t welcome-to-docker .
|
Stage 1: Build the React applicationFROM node:8.15.1-alpine as build-stage Set the working directory in the containerWORKDIR /usr/src/app Copy package.json and package-lock.jsonCOPY package*.json ./ Install dependenciesRUN npm --verbose install Copy the rest of the application codeCOPY . . Build the React applicationRUN npm run build Stage 2: Serve the React application using a lightweight web serverFROM nginx:alpine Copy the build artifacts from the build stage#COPY --from=build /app/build /usr/share/nginx/index.html Expose port 80 to access the applicationEXPOSE 80 Start NginxCMD ["nginx", "-g", "daemon off;"] |
Trying docker for windows for my 1st time!
Windows 11 and VS code both current versions.
Running the docker build -t welcome-to-docker . command returns an error " ERROR: failed to solve: process "/bin/sh -c npm install....."
This error persisted because my WSL2 machine , or my host machine, (I am not sure which ) did not have NPM installed already.
ie trying
This was solved via running 'sudo apt install npm' in the WSL2 Ubuntu VM, and then running the welcome to docker build script again.
The container then built successfully.
The text was updated successfully, but these errors were encountered: