0

我正在开发 docker api python 客户端,我已经成功完成了构建映像,但现在我需要将该 docker 映像推送到 dockerhub 存储库。

这是我尝试过的:

来自views.py

            client = docker.from_env()
            client.images.build(path=docker_folder, gzip=False, tag=deployment.name)
            image = client.images.get(deployment.name)
            print(image.short_id)
            print("start pushing your docker image to docker hub")
            auth_config = {
                'username': '***dockerhub-email ***',
                'password': '***Password***',
            }
            client.images.push('arycloud/istiogui', tag=deployment.name,
                               auth_config=auth_config)

它不返回任何错误,但图像未推送到 docker hub reoritoy 上。这是我正在使用的存储库:

https://hub.docker.com/r/arycloud/istiogui/

@Tarun 评论后更新代码

            client = docker.from_env()
            print("Start Building your docker image...")
            client.images.build(path=docker_folder, gzip=False, tag=deployment.name)
            image = client.images.get(deployment.name)
            print(image.short_id)
            print("start pushing your docker image to docker hub")
            client.login(username='***', password='***')
            client.images.push('arycloud/istiogui', tag=deployment.name)

之后我的图像仍然没有推送到 dockerhub 上!

4

1 回答 1

3

你可以试试这个

client.login(username='***', password='***')
for line in client.images.push('arycloud/istiogui', stream=True, decode=True):
    print(line)

它将打印基本上是错误或成功信息的输出

于 2019-12-10T05:46:29.540 回答