i trying make docker image generated tar file, problem thah tar file wats generates valid, , code worked before.
t = tarfile.open('dockerfile.tar',mode='w') file_name = tarfile.tarinfo("dockerfile") file_name.size = len(dockerfile) t.addfile(file_name, bytesio(dockerfile.encode('utf-8'))) file in static_files: t.add(static_files_path + file,arcname='root/'+file) file in files: if type(file["data"]) == str: file_name = tarfile.tarinfo('root/'+file["file"]) file_name.size = len(file["data"].encode()) t.addfile(file_name, bytesio(file["data"].encode())) else: file_name = tarfile.tarinfo('root/'+file["file"]) file_name.size = len(file["data"]) t.addfile(file_name, bytesio(file["data"])) t.close() docker_client = client(base_url=docker_host) c=open('dockerfile.tar','r') response = [line line in docker_client.build(fileobj=c, rm=false, tag=image_name, custom_context=true)] what get:
file "/usr/lib/python3.4/codecs.py", line 313, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) unicodedecodeerror: 'utf-8' codec can't decode byte 0x89 in position 3584: invalid start byte >>> data[3580:3590] b'\x00\x00\x00\x00\x89png\r\n' the problem in \x89png , why hapening? bug ?
ok, problem in:
c=open('dockerfile.tar','r') should be
c=open('dockerfile.tar','rb')
Comments
Post a Comment