Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker React App: 404s will fallback to /

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 ?

like image 747
SebNik Avatar asked Apr 29 '20 16:04

SebNik


2 Answers

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

like image 156
dwthien Avatar answered Sep 23 '22 18:09

dwthien


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)

like image 30
SoSo Avatar answered Sep 22 '22 18:09

SoSo