React App Exits Immediately with Docker Run Command

Last updated on October 1, 2020 Saul Goodman Loading... Post a comment

Problem

After 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:

[email protected] 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...

[email protected] 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 

Related Articles

guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x