Docker Community Forums

Share and learn in the Docker community.

Container attach via websocket

I tried writing a websocket client with C++ and Javascript, in both case, wireshark shows that nothing was coming back from the server after initial websocket handshake with a url like the following:


I tried writing something like ‘\r’ from my websocket client to server as either binary or text, but nothing came back from server.

On the server side, there is error in syslog (not much details even when “dockerd -D”):
dockerd[5538]: time=“2018-02-06T19:04:36.695828481-08:00” level=error msg=“Error attaching websocket: %!s()”

Does anyone have a clue what’s going on?
Thanks much.

$ docker version
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:23:31 2017
OS/Arch: linux/amd64

Version: 17.06.0-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:19:04 2017
OS/Arch: linux/amd64
Experimental: false

need a whole bunch more information…
what is running inside the container?


Calling REST API attach (without websocket) works fine in my simple test terminal code.


docker cli command attach does not support websocket option.
I also searched docker go API, but its ContainerAttach does not seem to support WebSocket option, python attach API supports websocket, but I haven’t tried yet.

python sdk works, will check the traffic capture to see why my REST client code does not work.

@leikong could you share the python code you used to attach to a container via websocket? Did you use the attach_socket function?

I’m just looking for an example somewhere of setting up a websocket stream to a container’s stdout via the python docker SDK