1

I created a Linux container in docker with all the packages and dependencies I need it for my school project. I am aware you can deploy react app containers and use Docker for deployment, although I did not want that. I just need it a Linux container with everything installed so all the members in the team will use the same versions of npm and node. After building the container I ran inside my workdir folder:

npx create-react-app my-app cd my-app npm start

and this is what it shows enter image description here

which means that the app is running locally in my computer how can I see it locally in my PC?

1 Answer 1

2

use this to run your image:

docker run -d -p 8080:8080 my_image

-p 8080:808 - will map your docker container port to your localhost 8080 port, and you should be able to just go on http://localhost:8080 to see it. (assuming that npm start is starting server on 8080 inside of your docker)

-d means in detached mode, your going to start docker and stay outside of it.

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

4 Comments

It is not working. Error response from daemon: driver failed programming external connectivity on endpoint cs-space-zero_cs-space_run_d2561811c6df (af5cdf962a14886985b30b9d18ce473c8ce18f8314d0e09795ed61ba8dc6af46): Bind for 0.0.0.0:8080 failed: port is already allocated That is the error I get. I do not want to use -d I want to be working within my container.
@specter_93 You have already an application using port 80, that's the reason for: port is already allocated
I fixed that but still does not solve the problem. When I navigate to localhost:8080 I cannot see the react app.
once in docker try duing curl -XGET http://localhost/index.html assuming you have index.html in your site - most probably it is going to return some error, which would mean that you app not working at all (npm start should produce some logs regarding this), thus no docker fault.

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.