code: def push_to_registry(self, image, image_tag: str):
          
          # already tagged, so it's already pushed
          if f"{self.use_registry_name}:{image_tag}" in image.tags:
              return
  
          image.tag(self.use_registry_name, image_tag)
  
          result = self.client.images.push(self.use_registry_name, image_tag)
  
          result = result.strip()  # remove empty line at the end of output
  
          # the last can have one of two outputs, either
          # {"progressDetail":{},"aux":{"Tag":"<tag>","Digest":"sha256:<hash>","Size":<size>}}
          # when the push is successful, or
          # {"errorDetail": {"message":"<error_msg>"},"error":"<error_msg>"}
          # when the push is not successful
  
          last_line = json.loads(result.split("\n")[-1])
  
          if "error" in last_line:
              self.client.images.remove(f"{self.use_registry_name}:{image_tag}")
              raise PushToRegistryError(f"Push of the image failed because of: {last_line['error']}", full_output=result)
  
          logger.info("Pushed image to registry %s:%s", self.use_registry_name, image_tag)
          logger.debug("Info:\n%s", result)
docs: Pushes a local image to a registry based on the ``use_registry_name`` setting.
  
          :type image: docker.models.images.Image
          :raise PushToRegistryError: If the push fails.