4

I have a React app that I would like to Dockerize for Windows containers. this my Dockerfile:

FROM stefanscherer/node-windows

# Override the base log level (info).
ENV NPM_CONFIG_LOGLEVEL warn

# Expose port for service
EXPOSE 80

# Install and configure `serve`.
RUN npm install -g serve

# Copy source code to image
COPY . .

# Install dependencies
RUN npm install

# Build app and start server from script
CMD [ "npm", "start" ]

The image is successfully built, but when I try to run it I get this error:

Error response from daemon: container 3b4b9e2bab346bbd95b9dc144429026c1abbe7f4d088f1f10d4c959364f50e9e encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLine":"npm start","WorkingDirectory":"C:\\","Environment":{"NPM_CONFIG_LOGLEVEL":"warn"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.

I am new with Docker so I not sure if I am missing something. Any ideas?

grifoxx
  • 191
  • 6

1 Answers1

0

This error probabily is because the image base is nanoserver in this case, and then the react-scripts don't works well. Also the docker images from stefanscherer/node-windows arn't updates (the latest versions of NodeJs in these images are 12.x).

Because this, I made one new docker image with some LTS versions as 14.19.0, 16.17.0 for example.

The docker image is henriqueholtz/node-win, where the tags are the NodeJs versions.

Note: For now, the NodeJs don't have official image to windows container.

In the README in docker hub, you can see one example and the links to some articles with more examples.

See some articles with examples:

Below one example to run your create-react-app, for example (obviously, you must change the volume to your folder - use powershell):

docker run -t -p 3000:3000 --name=my-own-cra-windows-container -v C:\Projects\my-own-cra\:C:\app\ henriqueholtz/node-win:16.17.0 cmd /c "npm -v & node -v & npm start"

Henrique Holtz
  • 326
  • 2
  • 6