Exposing docker container ports in Windows

You might want to map a running docker container to your localhost’s port, but you can’t. For example, you run your image with

docker run -p 8080:8080 myImage

and expect to hit the docker container at http://localhost:8080 … but that doesn’t work.

In Windows, because Docker runs as a VM, it’s localhost refers to the VM’s localhost.

To find out the VM’s ipaddress, run this command

docker-machine ip default

sample output: 192.168.99.100

then you can access the image at http://192.168.99.100:8080

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s