您需要对此进行低级pull()
调用(docs)。这是一个例子:
>>> import docker
>>> import json
>>> client = docker.APIClient(base_url='unix://var/run/docker.sock')
>>> for line in client.pull('busybox', stream=True, decode=True):
... print(json.dumps(line, indent=4))
{
"status": "Pulling from library/busybox",
"id": "latest"
}
{
"status": "Pulling fs layer",
"progressDetail": {},
"id": "e5d9363303dd"
}
{
"status": "Downloading",
"progressDetail": {
"current": 8635,
"total": 764663
},
"progress": "[> ] 8.635kB/764.7kB",
"id": "e5d9363303dd"
}
{
"status": "Downloading",
"progressDetail": {
"current": 764663,
"total": 764663
},
"progress": "[==================================================>] 764.7kB/764.7kB",
"id": "e5d9363303dd"
}
{
"status": "Verifying Checksum",
"progressDetail": {},
"id": "e5d9363303dd"
}
{
"status": "Download complete",
"progressDetail": {},
"id": "e5d9363303dd"
}
{
"status": "Extracting",
"progressDetail": {
"current": 32768,
"total": 764663
},
"progress": "[==> ] 32.77kB/764.7kB",
"id": "e5d9363303dd"
}
{
"status": "Extracting",
"progressDetail": {
"current": 764663,
"total": 764663
},
"progress": "[==================================================>] 764.7kB/764.7kB",
"id": "e5d9363303dd"
}
{
"status": "Extracting",
"progressDetail": {
"current": 764663,
"total": 764663
},
"progress": "[==================================================>] 764.7kB/764.7kB",
"id": "e5d9363303dd"
}
{
"status": "Pull complete",
"progressDetail": {},
"id": "e5d9363303dd"
}
{
"status": "Digest: sha256:c5439d7db88ab5423999530349d327b04279ad3161d7596d2126dfb5b02bfd1f"
}
{
"status": "Status: Downloaded newer image for busybox:latest"
}