6

I am building an React Javascript App with npm and want to deploy it on docker.
When I run the App locally with:

npm start

It all works just fine. But then when I build a Docker Image and test it I get follwing error:

$ docker run react-app

> [email protected] start /
> react-scripts start

ℹ 「wds」: Project is running at http://172.17.0.2/
ℹ 「wds」: webpack output is served from
ℹ 「wds」: Content not from webpack is served from /public
ℹ 「wds」: 404s will fallback to /
Starting the development server...

The Dockerfile looks like:

FROM node:latest
COPY ./keycloak-react .
RUN npm install typescript
RUN npm install node-sass
RUN npm install sass
RUN npm install fibers
RUN npm install
EXPOSE 3000
CMD [ "npm", "start", "run", "--host", "0.0.0.0"]

I don't know what to do any ideas ?

4
  • What's the problem ? What's npm start run ? Shouldn't it be npm run start or simply npm start ?
    – Mickael B.
    Apr 29, 2020 at 16:17
  • with npm start I have the same issue
    – SebNik
    Apr 29, 2020 at 17:51
  • What is the issue ??
    – Mickael B.
    Apr 29, 2020 at 18:21
  • 404s will .... the same problem appears when using only npm start
    – SebNik
    Apr 29, 2020 at 18:46

3 Answers 3

8

I just fixed, let add stdin_open: true to docker-compose to fix it.

link info: https://github.com/facebook/create-react-app/issues/8688

2
  • Okay, Thank you. So what exactly should I do ?
    – SebNik
    May 1, 2020 at 9:27
  • What I mean by this, what should I change in my Dockerfile.
    – SebNik
    May 1, 2020 at 10:47
3

I added -i -t flags in the docker run command and it worked fine for me

-i leaves the stdin of the container opened

-t assigns a pseudo-tty (for interactive session with shell)

My command was:

docker container run -i -t image_name

I think

docker run -i -t image_name

will work as well (don't know the real difference between the 2)

2

You have 3 options:

  1. Add stdin_open: true to your docker-compose command
  2. Add an CI=true as an environment variable
  3. Downgrade your react-scripts to 3.4.0

I got stuck for several hours on this really annoying error but trying to use it on my CircleCI environment... But this is a Docker Question! (you might think), and yes it is, but CircleCI also does use Docker... Anyway, I found myself in this same Issue URL that @dwthiemn mentioned above and it turns out that react-scripts 3.4.1 does looks for those specific values, otherwise the dev server is closed.

enter image description here

But If by some mean you choose to downgrade your react-script version, you should verify if there's any dependency conflict because of that

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.