如何使用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'
最佳答案
我认为您应该使用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)
https://docker-py.readthedocs.io/en/stable/images.html?highlight=push#docker.models.images.ImageCollection.get
关于docker - docker py并构建并推送AttributeError: 'Image'对象没有属性 'push',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50897077/