docker-py: _stream_helper returns invalid JSON or cannot decode

docker-py 1.8.0

python 3.5.0

docker Version 1.11.1-beta10 (build: 6662)

OS Mac OS X 10.11 Beta 15A279b


While using https://github.com/6si/shipwright, I found that invalid JSON was being returned by docker-py. According to the docs, the output of client.build should be an iterable of valid JSON objects encoded as strings (or the JSON objects decoded if decode=True is passed). e.g.

'{"stream":"Step 1 : FROM ubuntu:xenial\\n"}'

However, I have found while using the setup listed above, that it is returning strings like:

'{"stream":"Step 1 : FROM ubuntu:xenial\\n"}\r\n{"stream":"Step 2 : COPY foo\\n"}\r\n'

(Note the trailing CRLFs as well, differs from the documentation)

I suspect this issue is being triggered by the Docker side of things, it looks like the chunks in the chunked response used to align exactly with JSON objects, but now no longer do, although I’m not familiar enough with the Docker API to know if this is correct.

I also suspect I reached this issue because of the pre-release Docker installation, however I see that docker-py doesn’t list compatible Docker versions, which makes it difficult to know if this is a bug or unimplemented functionality.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 18 (6 by maintainers)

Commits related to this issue

Most upvoted comments

1.10.0 is now available on pypi.

This is still an issue for me as well (I’m having this in Ansible’s docker_image module and got here through ansible/ansible-modules-core#4116 and then #4116).

The fix proposed in #1081 works perfectly for me. I suggest that gets merged.