Websockets not connected on localhost

Expected behavior

Running the websocket webserver in Docker on localhost on OSX should allow connecting from browser to localhost websockets.
Using (Docker for Mac 1.12.0-rc4-beta19 (build: 10258)
c84feba3aa680f426b8fa66f688388611267cd53)

Actual behavior

Websockets cannot be connected

Steps to reproduce the behavior

  1. Create this Dockerfile

FROM ubuntu:14.04.2 RUN apt-get update && \ apt-get install -y wget build-essential python python-dev python-distribute python-pip git RUN mkdir -p /opt/app && git clone https://github.com/dpallot/simple-websocket-server.git /opt/app WORKDIR /opt/app CMD python SimpleWebSocketServer/SimpleExampleServer.py --example chat
2. Build the image by docker build -t socket-test .
3. Run the image by docker run -d socket-test
4. Download the website wget https://raw.githubusercontent.com/dpallot/simple-websocket-server/master/SimpleWebSocketServer/websocket.html
5. Open websocket.html and browser at least two times and click connect (the websockets won’t be connected)

It works fine with docker run -p 8000:8000. Solved.