Docker Community Forums

Share and learn in the Docker community.

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)

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 /opt/app WORKDIR /opt/app CMD python SimpleWebSocketServer/ --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
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.