Unable to connect to tomcat running in Docker (Connection refused)
Asked Answered
C

1

7

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.

Caeoma answered 2/9, 2015 at 17:4 Comment(3)
I think you might need to forward port from boot2docker-vm to your host machine.Quad
I opened up Oracle VM VirtualBox Manager, and it looks like I have two VMs... one called boot2docker, which is stopped, and one called "default", which is running. Are there supposed to be 2 VMs? Or is this because I migrated from the old boot2docker version? Should I delete them both and make boot2docker create a new one? How can I make boot2docker do the right thing by default, so I don't have to mess with the settings in VirtualBox?Caeoma
I would say, clean everything. And yes, when you install boot2docker on Windows and Mac, it gives you VM and inside that VM docker daemon runs. Boot2docker should be in running state.Quad
M
17

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.

Mesomorphic answered 2/9, 2015 at 19:3 Comment(1)
My Pleasure @jayeff :) :)Mesomorphic

© 2022 - 2024 — McMap. All rights reserved.