4

I am using boot2docker. I run one image at the daemon mode which starts grunt server at port 3000. This is the command I used to start it up.

That image has already exposed port 3000

docker run -d -P --name dummy image_name grunt server
docker ps
3af4ba19c539        image_name:latest   "grunt server"      54 minutes ago      Up 54 minutes       0.0.0.0:45000->3000/tcp   dummy

and then run into the same container to "curl" the web server.

docker exec -it 3af4ba19c539 /bin/bash 
curl localhost:3000 

It gets the html.

However, when I try to connect it in my mac pc. It said "Connection refused."

curl $(boot2docker ip):45000
//curl: (7) Failed connect to 192.168.59.103:45000; Connection refused

I try to solve this problem by using VBoxManage, but it is not working either

VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port45000,tcp,,45000,,45000"

May I know how to solve this problem. Many thanks in advance

2
  • Was the container running when you did a modifyvm? Because if it was, then a controlvm was required: see stackoverflow.com/a/29998490/6309. Commented May 24, 2015 at 10:25
  • Log into the container and post the ouput of netstat -ant Commented May 24, 2015 at 20:19

1 Answer 1

8

I need to see the source of your application to be sure, but I'm willing to bet you've bound to the local loopback interface (127.0.0.1 or localhost) in your application. If you instead bind to 0.0.0.0 to listen to all interfaces, you should find it is accessible from the outside.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.