I am trying to containerized a sample react.js app inside docker.
My docker file is as follow and I am in the working directory of the project
FROM node:10-alpine
RUN mkdir -p /var/tmp/thermodocker && chown -R root:root /var/tmp/thermodocker
WORKDIR /var/tmp/thermodocker
COPY * ./
USER root
RUN [ "npm", "install","--python","python2" ]
EXPOSE 3000
CMD [ "npm", "run" ]
I can successfully create image
[root@******]# docker build -t thermo-api .
...
Successfully built c6697819c3e1
Successfully tagged thermo-api:latest
Hwoever, when I want to run the application, it doesn't come up as a running docker image
[root@******]# docker run -d -p 3000:3000 --name thermo-api-app thermo-api
51b873637ac12ee2a89d075edf1953c29b41826b6b3847659d7763d42516916a
INFO[2020-07-29T01:01:30.555414295Z] shim containerd-shim started address="/containerd-shim/moby/51b873637ac12ee2a89d075edf1953c29b41826b6b3847659d7763d42516916a/shim.sock" debug=false pid=8021
[root@********]# INFO[2020-07-29T01:01:31.081201052Z] shim reaped id=51b873637ac12ee2a89d075edf1953c29b41826b6b3847659d7763d42516916a
INFO[2020-07-29T01:01:31.088559217Z] ignoring event module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
[root@******]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@thermo-breast-cancer-devvm1 thermo-api]#
I am not sure where I am doing mistake?
[PS:] Per comments I have changed the CMD to
RUN [ "npm", "install","--python","python2" ]
however I can not build image
Step 6/8 : RUN [ "npm", "install","--python","python2" ]
---> Running in 77155726f35e
INFO[2020-07-29T01:35:38.577900480Z] shim containerd-shim started address="/containerd-shim/moby/77155726f35ed6f7464d6e801d767221d62e0e31fd7e342835b6d861e3694b57/shim.sock" debug=false pid=8717
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/python2 failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-07-29T01_35_44_304Z-debug.log
INFO[2020-07-29T01:35:44.354721669Z] shim reaped id=77155726f35ed6f7464d6e801d767221d62e0e31fd7e342835b6d861e3694b57
INFO[2020-07-29T01:35:44.361799117Z] ignoring event
docker logs thermo-api-appor repeating thedocker runcommand without the-doption? What benefits are you hoping to get from Docker over just directly running Node here?npm install. Just omit that step (tail -f /dev/nullis a reasonable do-nothing CMD to keep the container alive while you are troubleshooting), then and exec into the container and run the npm install command yourself interactively to troubleshoot. You will likely feel more familiar and comfortable debugging this way.