Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to connect to tomcat running in Docker (Connection refused)

I am very new to Docker, and I am trying to run the default tomcat image. I see that the container is running, but when I try to hit it from my web browser, I get "CONNECTION REFUSED".

What is going on here?

Details

I have the Docker Toolbox installed on my Windows 7 PC. I migrated my boot2docker VM from an older version of boot2docker. (It didn't have much on it... just the "hello world" image.)

In the Docker Quickstart Terminal, I was able to start my new tomcat container with the following command:

docker run -i -p 8080:8080 --rm tomcat:8-jre8

I was able to verify that tomcat is up and running using the following commands:

docker ps
docker exec -i <containerId> bash

Then, within the bash shell:

curl localhost:8080

From this curl, I get back the expected HTML response.

However, if I run the curl command from the Docker Quickstart Terminal directly:

curl localhost:8080

...I get "connection refused".

Now here's something puzzling... if I run

boot2docker ip

...it gives me an error that "boot2docker-vm" is not running. How can my container be running when the boot2docker VM is down? There's something going on here that I really don't understand.

If I run "boot2docker up", I am able to get an IP address, but I still can't access tomcat from that IP address.

like image 550
RMorrisey Avatar asked Sep 02 '15 17:09

RMorrisey


1 Answers

You are using docker toolbox. The boot2docker has been depricated. Now every docker daemon (VM) is managed by Docker Machine

To see which VMs are running, use the command

docker-machine ls

It will show you the default VM running on the system along with its IP address and you can access Tomcat from that IP at port 8080. Read more about docker-machine to see how to manage multiple VMs etc.

like image 191
Sachin Malhotra Avatar answered Sep 18 '22 10:09

Sachin Malhotra