Trouble running y-websocket via Docker

I recently discovered yjs and it’s very impressive to say the least!

I’m having issues running the y-websocket server via the Dockerfile. It runs fine without docker (by ./bin/server.js, I can visit localhost:1234 and it responds okay).

On starting the docker container, I see the message running at 'localhost' on port 1234, but visiting localhost:1234 gives me localhost didn’t send any data..

Here are my docker commands:
docker build -t yws .
docker run -it --rm -p 1234:1234 --name yws yws

Response from docker:
> y-websocket@1.3.11 start /home/node/app
> node ./bin/server.js

running at 'localhost' on port 1234

(But nothing on localhost:1234)

I’m running docker on mac. I believe I must be missing something about docker networking. But I’m wondering if any of you came across this and happen to have a fix.


Hi @royanin,

I don’t use docker. I hope that somebody else can help you.

If you figure out the issue, it would be great if you could share it (and possibly create a PR to the y-websocket/Dockerfile if that fixes the problem).

Hi @dmonad,
Thank you for your response. Yes, I’ll keep looking, and open a PR if we find a solution.


Hey, if you can run it without docker it would work with docker as well. Docker does not introduce any special treatment of software you want to run.

I had success with running demo server from examples.

(can’t paste any links to link the demo-server, you can find it in examples)

You must set ENV HOST= in your Dockerfile.
Or you can docker run -it --rm -p 1234:1234 -e HOST= --name yws yws.
Node server can not be visitied if this host is localhost or in docker.