Mike
Mike

Reputation: 2044

Can't expose web server using docker on OSX

I have a docker image that runs a webserver and I would like to access it from my local OSX, but I'm having issues.

I start the container with: docker run -p 8000:8000 <container-name>

and I can see log messages telling me that the local server is listening on localhost:8000

I am able to get a successful response from running:

docker exec <IMAGE-ID> curl "http://localhost:8000/"

Addresses I've tried on my local OSX are:

Neither of those work. Any suggestions?

I've tried the same process on Ubuntu 16.04 and no luck their either.

Upvotes: 0

Views: 1065

Answers (1)

John Weldon
John Weldon

Reputation: 40789

The newer versions of docker use vpnkit on OSX to manage the port forwarding to the containers... you should allow vpnkit through your firewall if you want to expose the container ports.

Also, in your Go code, make sure to bind to 0.0.0.0 rather than 127.0.0.1 for your webserver code.

Upvotes: 2

Related Questions