0

I am trying to run a react app in a docker image however it exits without an error message

DokerFile

# pull official base image
FROM node:13.12.0-alpine

# set working directory
WORKDIR /app

# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH

# install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install

# add app
COPY . ./

# start app
CMD npm start --port 3000

then I proceeded to build

docker build -t react-app:latest .

then I run

docker run -p 7000:3000 react-app:latest

gives the following out put

enter image description here

then exits out

this is what I see on the browser

enter image description here

1 Answer 1

1

Your docker closes because the tty is not enabled. In order to work, you have to run the docker with

docker run -t -p 7000:3000 react-app:latest

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

But this should be only for testing/development. In production you should build your react app and then serve it with serve or with nginx

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

2 Comments

I am trying to run the -d option to run in the background it doesnt seem to be working any advise?
run it using docker run -tid

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.