0

I'm working on docker api python client,I have successfully done with build image, but now I need to push that docker image to dockerhub repository.

Here's what I have tried:

From 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)

it doesn't return any error but image not pushed on docker hub reporitoy. Here's the repository I'm using:

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

Updated code after @Tarun's comments

            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)

after that still my image doesn't pushed on dockerhub!

Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150
  • Try adding `client.login(username, password)` and remote the `auth_config` and see if that helps – Tarun Lalwani Aug 02 '17 at 12:49
  • did you mean like this: `client.images.push('arycloud/istiogui', tag=deployment.name,auth_config=client.login(username='***', password='***'))` – Abdul Rehman Aug 02 '17 at 13:36
  • no. Two lines of code `client.login(username='***', password='***')` and `client.images.push('arycloud/istiogui', tag=deployment.name)` – Tarun Lalwani Aug 02 '17 at 14:17
  • ok, now it doesn't throw any error but still image has not pushed on dockerhub, is there something wrong still? – Abdul Rehman Aug 02 '17 at 15:50
  • See this video for some help https://youtu.be/DK1ew1HpmeY?t=1907 and do the socat debugging and see what the docker server is getting from python – Tarun Lalwani Aug 02 '17 at 16:42

1 Answers1

3

You can try this

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

it will print the output which is basically the error or success info

vishal
  • 1,368
  • 2
  • 15
  • 34