Alex Edelstein
Alex Edelstein

Reputation: 528

Docker on Mac: Can't view ports

I'm running boot2docker on Yosemite. I have no trouble creating containers and using them in boot2docker. I also can successfully connect via http to the docker daemon running in boot2docker's vm. However, when I create a container with Revel and start Revel up, I cannot connect to Revel's port 9000 from my browser.

I was following this approach: http://www.medding.me/blog/2014/09/06/setting-up-a-docker-environment-for-golang-development-part-1/

Here's the running Revel server:

INFO  2015/05/07 20:19:00 revel.go:329: Loaded module static
INFO  2015/05/07 20:19:00 revel.go:329: Loaded module testrunner
INFO  2015/05/07 20:19:00 revel.go:206: Initialized Revel v0.12.0 (2015-03-25) for >= go1.3
INFO  2015/05/07 20:19:00 run.go:57: Running revel3 (alexed1/revel3) in dev mode
INFO  2015/05/07 20:19:00 harness.go:165: Listening on :9000

When I connect to 192.168.59.103:9000 with a browser, I get ERR_CONNECTION_REFUSED.

I've tried a couple of different things:

  1. The dockerfile has EXPOSE(9000) in it;
  2. The VirtualBox client has been configured this way: http://screencast.com/t/KiRdimWVnwqS in accordance with the direction of http://odewahn.github.io/docker-jumpstart/boot2docker.html. I've tried using both localhost and 127.0.0.1 for the host value.

As you can see, no port information shows up on the running container:

Upvotes: 3

Views: 1583

Answers (1)

schmunk
schmunk

Reputation: 4708

EXPOSE is not for "exposing" ports to the host, it's for interconnecting containers, see docs.

As mentioned from jm_____ you have to forward the port of the container to your boot2docker host :

docker run -p 40001:9000 the/image/name

and then access it with:

open http://192.168.59.103:40001

or by finding the port with docker ps as you tried already.

PS: There's no PORT in a Dockerfile, but you can specify this in a docker-compose.yml file.

Upvotes: 2

Related Questions