docker api, attaching container returns extra characters

I’m consuming docker api from javascript in the browser,
I start one container that executes ‘composer install’ command then I attach to it to get the output.
Everything works but I get some extra characters at the beginning of each line

    -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 and B before installing word in this two line example in particular, but in reality are random letters or numbers.

  • Can not deserialize instance of int out of VALUE_FALSE token while readng docker info client.infoCmd().exec();(docker java api version 0.10.4)
  • Get docker API engine exec output
  • AWS ECS weird docker behavior
  • Unable to install node 7.5.0
  • Docker: cannot open port 8080
  • Not able to communicate with server on https when launched from marathon and docker
  • do I need to parse or process the output of attached container before displaying it ?

    Note: Not only from browser but from terminal curl command too, also getting same random characters at beginning of almost line

    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' 

  • Unable to build Dockerfile Error: Unable to access jarfile /dev/docker-files/billing/wlp-extended-
  • Docker-compose hanging on pulling image where Dockerfile doesn't
  • Where are Docker images stored on the host machine?
  • How to stop all containers when one container stops with docker-compose?
  • NFS Volumes in Docker/Docker-Compose
  • What is the purpose of the Docker build context?
  • One Solution collect form web for “docker api, attaching container returns extra characters”

    Turns out that this is documented here

    I just overlooked because the text format I thought was the rest of the response but it was in fact documentation.
    It’s been clarified by @soullou user in

    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.
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.