如何使用docker py构建并推送到服务器?
docker_path = "/path/to/dockerfile/puredocker"
build_image = docker_client.images.build(path=docker_path,tag=tag)
image = build_image[0]
print ('build_image:',build_image)
for line in image.push(registry_name, stream=True):
print (line)
我的形象不是吗?
build_image: (<Image: 'testme:latest'>, <itertools._tee object at 0x10d9d0ec8>)
因此:image = build_image [0]
for line in image.push(registry_name, stream=True):
AttributeError: 'Image' object has no attribute 'push'
答案 0 :(得分:1)
我认为你应该使用get
方法。
docker_path = "/path/to/dockerfile/puredocker"
client.images.build(path=docker_path, tag=tagged)
image = client.images.get(<the name of the image>)
print(image.short_id)
client.images.push('registry/registry', tag=tagged)