Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access application URL hosted in docker container?

Tags:

docker

I hosted our application inside a docker container. When I run docker ps command, it gave info like below.

CONTAINER ID        IMAGE                      COMMAND             CREATED             STATUS              PORTS                                                                                                                        NAMES
6405daf98246        rdarukumalli/testapp-master   "/bin/bash"         4 hours ago         Up 4 hours          0.0.0.0:32797->443/tcp, 0.0.0.0:32796->8000/tcp, 0.0.0.0:32795->8080/tcp, 0.0.0.0:32794->8443/tcp, 0.0.0.0:32793->9997/tcp   insane_poincare

I am trying to access this application from my machine with the following URLs. Nothing worked so far.

0.0.0.0:32795/testapp/login.jsp
0.0.0.0:8080/testapp/login.jsp
localhost:8080/testapp/login.jsp
localhost:32795/testapp/login.jsp

However, if i give the command "curl http://localhost:8080/testapp/login.jsp" inside bash of docker container, I can login page html is coming.

Can some one help me in understanding these URL mappings and what URL i need to use to access this login page outside docker container?

like image 408
Ram Avatar asked Jul 04 '17 10:07

Ram


People also ask

How do I find the URL of a container?

A Web URL of a container is derivied from its Template URL i.e. Web URL = Container ID + - + Template URL .

How do I access the web interface of a Docker container?

Once the image has been fully built and the Docker container is running you can visit http://localhost:8080/vnc.html where you will be prompted to insert the password specified in the docker file: password1 by default.


2 Answers

Try curl http://localhost:32795/testapp/login.jsp.

Your docker ps shows that container's port 8080 is bound to external port 32795 : [...] 0.0.0.0:32795->8080/tcp [...]

like image 88
Sébastien Helbert Avatar answered Oct 06 '22 03:10

Sébastien Helbert


docker ps command shows the running container which displays the port your application is running. On browser type http://localhost:54529/your_application_page. if you are running application locally, then this is the port which needs to be changed in browser to access container application.

like image 29
Mohan Sharma Avatar answered Oct 06 '22 04:10

Mohan Sharma