问题描述
这是将图像从 dockerhub
拉到服务器的代码,然后我想将这些图像推送到我的本地注册表,然后从服务器中删除它们。
import docker #import subprocess**
def dock_pull(path):
#yaml_file = open(path)
for line in path.readlines():
s = line.rstrip().replace(' ','')
s = s
if s[0:5] == "image":
image = s[6:]
image_name = image[:image.find(':')]
version = image[image.find(':') + 1:]
print(image)
print(image_name)
print(version)
if version == "latest":
version = ''
image=client.images.pull(image_name,tag=version)
# docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
# Then docker push using that same tag.
# docker push NAME[:TAG]
image.tag(f"localhost:5000/{image_name}")
client.images.push(f"localhost:5000/{image_name}")
client.images.pull(f"localhost:5000/{image_name}")
yaml_file=open("C:\\Users\\alialhoush\\Desktop\\Desktop\\didi-image-verwaltung_docker\\didi-image-verwaltung_docker\\test.yaml")
'C:\\didi\\branch\\didi\\Imagemanagement\\docker.yaml','1*.1**.2**.*','*idi')
dock_pull(yaml_file)
# dock_pull("C:\\Users\\George\\PycharmProjects\\docker_project\\test.yaml")
print(client.images.list()
图像被拉取,但不能推送到本地注册表!我希望有人能帮忙。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)