1

While starting a react app on azure Linux container following error is thrown. The image runs successfully on docker container in local machine.

[34mℹ[39m [90m「wds」[39m: Project is running at http://192.168.0.13/ [34mℹ[39m [90m「wds」[39m: webpack output is served from [34mℹ[39m [90m「wds」[39m: Content not from webpack is served from /react-assignment1/public [34mℹ[39m [90m「wds」[39m: 404s will fallback to / Starting the development server...

node:events:491 throw er; // Unhandled 'error' event ^

Error: spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ENOENT at ChildProcess._handle.onexit (node:internal/child_process:283:19) at onErrorNT (node:internal/child_process:476:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) Emitted 'error' event on ChildProcess instance at: at ChildProcess._handle.onexit (node:internal/child_process:289:12) at onErrorNT (node:internal/child_process:476:16) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -2, code: 'ENOENT', syscall: 'spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe', path: '/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe', spawnargs: [ '-NoProfile', '-NonInteractive', '–ExecutionPolicy', 'Bypass', '-EncodedCommand', 'UwB0AGEAcgB0ACAAIgBoAHQAdABwADoALwAvAGwAbwBjAGEAbABoAG8AcwB0ADoAMwAwADAAMAAiAA==' ] }

Node.js v18.14.1

1
  • let's see your dockerfile. Commented Feb 20, 2023 at 15:37

1 Answer 1

0

I have tried reproducing the same using the steps below and got positive results.

Step 1: Create react app using the below command.

#npx create-react-app <app-name>

Refer to this link Create a New React App – React (reactjs.org) for more information on creating react app.

Step 2: Write Dockerfile and place it in the root folder of the react application.

FROM node:18-alpine3.16
WORKDIR /app
COPY . /app
RUN npm install
RUN npm run build
CMD ["npx", "serve", "-s", "build"]

enter image description here

Step 3: Build the Dockerfile with the below command and verify the docker image.

 $docker build -t <image_name> <location of the docker file> (“.” Indicates current working directory) 
 `$docker image`s --> to check for images

enter image description here

Step 4: Run the image locally using the below command and access it on the browser.

$docker run -d -p <host port>:<container port> <image name>

enter image description here

enter image description here

Step 5: Tag the docker image with the ACR login server name and push it to ACR.

$docker tag reactappaci10:latest humbleacr.azurecr.io/reactappaci10:latest
$docker images
$docker push humbleacr.azurecr.io/reactappaci10

enter image description here enter image description here

Step 6: Create Azure Container Instance with the below configuration.

enter image description here

Note: ACI port and container port must be the same.

enter image description here

Now access the [ip address:port] in the browser.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.