Docker api,附加容器返回额外的字符
docker api, attaching container returns extra characters
我正在浏览器中使用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之前,但实际上是随机的字母或数字。
我需要解析或处理附加容器的输出显示之前?
注意:不仅从浏览器,也从终端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
这里记录了这一点http://docs.docker.com/reference/api/docker_remote_api_v1.13/attach-to-a-container
我只是忽略了,因为我认为文本格式是响应的其余部分,但它实际上是文档。@soullou用户已经在https://github.com/docker/docker/issues/7375#issuecomment-51462963
中澄清了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.
相关文章:
- 从JavaScript中正确返回html中的特殊字符
- 为什么Angularjs服务返回的是字符数组而不是对象数组
- 如何使用match返回字符串中的字符
- 尊重“; 〃;从HTML显示中的API响应返回的换行符(和特殊字符)
- 请求返回 unicode 替换字符
- Javascript正则表达式,返回连字符和空格后面的数字
- 为什么这个正则表达式返回前面的字符
- 使用onkeypress/onkeydown返回自然语言字符,同时保留退格功能
- 从nodejs-crypto返回的字符串中修剪非ascii字符
- Typeahead.js-特殊字符返回为“”&#230"等
- 正则表达式搜索短语,在短语后返回“n”个字符
- Object.keys(obj).length 返回字符总和而不是记录总数
- 为什么这是 for 循环返回字符的索引而不是整个属性
- Javascript - 如何获取字符串,打印单词,字符,空格,平均单词长度的#并作为对象返回
- 我如何调整这个 javascript 以返回一个后代号,减去最后 2 个字符
- 在 PHP 子字符串中返回这些类型的字符
- 返回字符对于SimpleText区域和Validation TextBox的混合无效
- Json返回字符
- jQuery tokeninput插件,当返回1字符数字的结果时出现问题
- Javascript 字符串数组访问返回字符