rakeeee
rakeeee

Reputation: 1073

Docker tomcat not accessible from browser

I have started a container with some ports open and tries to access the web interface of Tomcat from browser but it's not working.

1)docker run -ti --rm --name server -p 3456:5678 tomcat:8.0 // not working with localhost:3456
2)docker run -ti --rm --name server -expose 8080 tomcat:8.0 //not working localhost:8080
3)docker inspect server // to see the ip:port and tried to access using it as well but no luck

I am using CentOS7 with docker instaled.

Thanks

Upvotes: 1

Views: 7841

Answers (1)

Sebastian
Sebastian

Reputation: 17433

It is very simple:

  1. is not working because you are binding to container port 5678 which is not used by tomcat (see EXPOSE commands in Dockerfile)
  2. is not working because you did not bind to a host port (-p is missing)

This works:

docker run -ti --rm --name server -p 9090:8080 tomcat:8.0

Open localhost:9090 in your browser.

Upvotes: 7

Related Questions