client = docker.from_env()
data = client.containers.run("namecontainer:1.0", ['param'],detach=True)
file_json = data.get_archive(data, '/wd/out.json')
如何制作?如何获取文件out.json?我不明白。
答案 0 :(得分:1)
client = docker.from_env()
data = client.containers.run("deep_analize/show_exploit:1.0", ['Apache 1.3.42'], detach=True)
sleep(5)
file_json = data.get_archive('/wd/out.json')
stream, stat = file_json
file_obj = BytesIO()
for i in stream:
file_obj.write(i)
file_obj.seek(0)
tar = tarfile.open(mode='r', fileobj=file_obj)
text = tar.extractfile('out.json')
q = text.read()
print(q)