Kinda Code
Home/React/React App Exits Immediately with Docker Run Command

React App Exits Immediately with Docker Run Command

Last updated: February 13, 2023

Problem

When starting a Docker container with a React app inside by performing the following command:

docker run -p 3000:3000 [my-container-id]

Your React app may exit immediately with the output like this:

goodman@Mac-mini client % docker run -p 3000:3000 33c988fb2142

> [email protected] start /app
> 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 /app/public
ℹ 「wds」: 404s will fallback to /
Starting the development server...

goodman@Mac-mini client % 

This error is not on your side but caused by recent updates of the create-react-app library.

Solution

The solution is quite simple. All you need to do is just add the -it flag to your command:

docker run -it -p 3000:3000 [container-id]

In my case:

docker run -it -p 3000:3000 33c988fb2142 

Further reading:

You can also check our React category page and React Native category page for the latest tutorials and examples.

Related Articles