Can't acces my front application in the localhost

Yes, normally it should complain, but in this case there is a virtual machine so I could imagine the port would be used or reserved on the host, but Docker inside the VM could use it. It would be a bug, but it could happen.

1 Like

But now the port in the container is 35145, not 4200 like earlier? So, did you now use -p 80:35145? (And how come it changed to that high of a number? Anyway, I’d stop the one running on 4200.)

Hello sorry @avbentem i was in a other project.
So this page appeared because i started the cli of the container and run the ng serve --host 0.0.0.0 command, so it told me that the port 4200 was already take.
Now i rerun the project and in my Dockerfile i put the:
CMD [ng, serve, --host, 0.0.0.0]
This is the result:
Nothing happens always on localhost, tried same approach with the redirecting the traffic to port 80 nothing happenned.
and then worked with:
docker run -d -p 8080:4200 appname
idk why exactly this port works, if you have some explanation would really helpfull to have a full understanding of the thing

ng serve is for development and testing only, and is not a supported or secure way of deploying an application. You should to build your app using ng build and then deploy the distribution files. Here’s an example

1 Like

Hmm, i don’t think it was an Angular building problem because, i had already build the dist files locally then put them in the container image, i don’t know if the method to do it but it worked fine et gained some building time

It isn’t. If your binary needs some external library but the container does not have it, that won’t work. For example building an app on Ubuntu then copying it into an alpine container may not work. Do as @pgoldtho suggested to make sure everything works in a container.

1 Like

I got the same issue while working on a fastapi api. Everything was working in the container but the localhost:port was giving SITE CANN’T BE REACHED. The problem was not docker or the port but i forgot to precise the root in my main file. That is, for fastapi, i forgot to define @app.get(‘/’) followd by the root function. It worked for me.