Docker Community Forums

Share and learn in the Docker community.

Container attach via websocket


(Leikong) #1

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:

ws://myhost:2375/containers/657cf5d077b3/attach/ws?stdin=1&stdout=1&stderr=1&stream=1

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
Client:
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

Server:
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


(Sam) #2

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


(Leikong) #3

bash

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

Thanks


(Leikong) #4

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.


(Leikong) #5

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