Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript docker api,附加容器返回额外字符_Javascript_Api_Curl_Docker - Fatal编程技术网

Javascript docker api,附加容器返回额外字符

Javascript docker api,附加容器返回额外字符,javascript,api,curl,docker,Javascript,Api,Curl,Docker,我正在浏览器中使用javascript中的docker api, 我启动一个执行“composer install”命令的容器,然后附加到它以获得输出。 一切正常,但我在每行的开头都有一些额外的字符 -Installing assets using the hard copy option PInstalling assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework BInstalling

我正在浏览器中使用javascript中的docker api, 我启动一个执行“composer install”命令的容器,然后附加到它以获得输出。 一切正常,但我在每行的开头都有一些额外的字符

    -Installing assets using the hard copy option
    PInstalling assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
    BInstalling assets for Propel\PropelBundle into web/bundles/propel
在这个两行的例子中,p和B在安装word之前特别重要,但实际上是随机的字母或数字

我是否需要在显示之前解析或处理附加容器的输出

注意:不仅从浏览器,而且从terminal curl命令也可以,在几乎行的开头也可以得到相同的随机字符

curl 'http://localhost/dockerapi/containers/54053a10dc05b45c400b16733d2edd1cbfb6b6d877badf5cc26d3da7d2165375/attach?logs=1&stream=1&stdout=1' 
-X POST 
-H 'Origin: http://localhost' 
-H 'Accept-Encoding: gzip,deflate,sdch' 
-H 'Accept-Language: en-US,en;q=0.8,es;q=0.6' 
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36'
-H 'Accept: application/json, text/plain, */*' 
-H 'Referer: http://localhost/' 
-H 'Connection: keep-alive'
-H 'Content-Length: 0' 
--compressed

事实证明,这是记录在这里

我只是忽略了,因为我认为文本格式是响应的其余部分,但实际上是文档。 它已由@soulou user在中澄清

It is encoded on the first 8 bytes like this:

header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}

`STREAM_TYPE` can be:

-   0: stdin (will be written on stdout)
-   1: stdout
-   2: stderr

`SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of
the uint32 size encoded as big endian.