I have an app running inside a docker container on localhost:4200 (not 0.0.0.0:4200). How can I expose it to the host?
When I use -p 4200:4200
on docker run, I am not able to get to the app.
i.e. curl localhost:4200
or curl http://127.0.0.1:4200
or curl http://<ip from ifconfig>:4200
or curl http://0.0.0.0:4200
doesn't work.
However, docker exec <container-id> curl localhost:4200
works. This means that app started successfully but 4200 port on localhost from container is not exposed to the host.
I stopped the app and modified the app (on the same running container) to expose the app on 0.0.0.0:4200 instead of localhost:4200. After that, I am able to get to curl http://0.0.0.0:4200
.
I am trying to figure out on how can I expose the port on localhost from container to host (so that I don't have to modify my app).