0

I'm trying to create a container for my ReactJs project with nodejs. At first, it seems to be success, but am not able to access it through the port.

Following is my Dockerfile

enter image description here

package.json

enter image description here

Command I ran

 docker build -t <your username>/node-reactjs .

 docker run -p 9090:3333 -d <your username>/node-reactjs

As you can see, the container created successfully

enter image description here

But

enter image description here

I even tried to go inside the container and curl localhost:3333, it did return me the js file

I tried googling around, and many ways but seems like cant make it to work. I even tried the docker-compose way, but even worse. Cant even create the container.

Would really appreciate if someone can help me out on this.

Btw, is this the correct way to do for ReactJs?

Thanks.

Ninjoe Quah
  • 399
  • 6
  • 24

1 Answers1

0

After some hard time, I finally found the way to get it to work. Thanks to this Connecting webpack-dev-server inside a Docker container from the host

All I need to do is to add a parameter to the start script in the package.json as following

enter image description here

Noticed the

--host 0.0.0.0

That's what missing.

Community
  • 1
  • 1
Ninjoe Quah
  • 399
  • 6
  • 24
  • This is just for a test right (you know the dev server shouldn't be used for production - just checking!) – Dominic Jun 22 '16 at 08:15
  • yes, I'm aware of that. But I still don't know what should be done for production. Mind to enlighten me? – Ninjoe Quah Jun 24 '16 at 16:11