diff --git a/src/Docker/Manager/ImageManager.php b/src/Docker/Manager/ImageManager.php index 76932358..7a6db2d1 100644 --- a/src/Docker/Manager/ImageManager.php +++ b/src/Docker/Manager/ImageManager.php @@ -177,6 +177,39 @@ public function pull($name, $tag = 'latest', callable $callback = null) return $image; } + /** + * Push an image. + * + * @param string $name + * @param string $tag + * @param string $registryAuth + * @param callable $callback + * + * @throws \Docker\Exception\UnexpectedStatusCodeException + * + * @return Image + */ + public function push($name, $tag, $registryAuth, callable $callback = null) + { + if (null === $callback) { + $callback = function () {}; + } + + $response = $this->client->post(['/images/{image}/push', ['image' => $name, 'tag' => $tag]], [ + 'headers' => [ + 'X-Registry-Auth' => $registryAuth + ], + 'callback' => $callback, + 'wait' => true, + ]); + + if ($response->getStatusCode() !== "200") { + throw UnexpectedStatusCodeException::fromResponse($response); + } + + return new Image($name, $tag); + } + /** * Remove an image from docker daemon *