React App Exits Immediately with Docker Run Command

Updated: February 13, 2023 By: A Goodman Post a comment

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.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Related Articles