Connection refused on nginx docker container

If you on OS X 10.10.3 Yosemite or newer and using Docker for Mac, you will not have docker-machine or docker toolbox or DOCKER_HOST to worry about.

Just map the port on run command local-port:container-port

docker run --name my-web  -p 8080:80

docker-machine ip default
xxx.docker.machine.ip

Then

curl http://xxx.docker.machine.ip:32770

The issue is that your DOCKER_HOST is not set to localhost, you will need to use the IP address of your docker-machine, since you are using Docker Toolbox:

docker-machine ip default # should return your IP address.

See Docker Toolbox Docs for more information.