specify API version in url used to open the websocket. With version 1.28 and up, docker uses binary frame format for websockets which does not seem to work with FAYE websocket. For API version 1.27 and below, text frame format is used.

+ short fix improvement for empty responses
This commit is contained in:
Ralf Teusner
2017-09-29 16:09:42 +02:00
parent 5318a240d9
commit 2806d9bf85

View File

@ -72,7 +72,7 @@ class DockerClient
# Headers are required by Docker
headers = {'Origin' => 'http://localhost'}
socket_url = DockerClient.config['ws_host'] + '/containers/' + @container.id + '/attach/ws?' + query_params
socket_url = DockerClient.config['ws_host'] + '/v1.27/containers/' + @container.id + '/attach/ws?' + query_params
socket = Faye::WebSocket::Client.new(socket_url, [], :headers => headers)
Rails.logger.debug "Opening Websocket on URL " + socket_url
@ -399,6 +399,9 @@ class DockerClient
output = container.exec(['bash', '-c', command])
Rails.logger.debug "output from container.exec"
Rails.logger.debug output
if(output == nil)
kill_container(container)
end
result = {status: output[2] == 0 ? :ok : :failed, stdout: output[0].join.force_encoding('utf-8'), stderr: output[1].join.force_encoding('utf-8')}
end
# if we use pooling and recylce the containers, put it back. otherwise, destroy it.