Skip to content

Instantly share code, notes, and snippets.

@ivansharamok
Created September 26, 2017 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivansharamok/acc36673c1be6d73c32fb87472674001 to your computer and use it in GitHub Desktop.
Save ivansharamok/acc36673c1be6d73c32fb87472674001 to your computer and use it in GitHub Desktop.
Push docker image into ACR
<#
.Synopsis
Pushes docker image to Azure Container Registry. Requires Docker engine to be available and running on the machine that executes this script.
Requires az-cli >= 2.0.13
.Example
.\push-image2acr.ps1 -RegistryName myregistry -ImageName myImageWithTag
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)] $RegistryName,
[Parameter(Mandatory=$true)] $ImageName
)
$Error.Clear()
Trap
{
Write-Error $_.ErrorDetails.Message
Write-Error $_.InvocationInfo.PositionMessage
Write-Error $_.CategoryInfo.ToString()
Write-Error $_.FullyQualifiedErrorId
$e = $_.Exception
while ($e.InnerException) {
$e = $e.InnerException
$msg += "`n" + $e.Message
}
break;
}
# login to ACR
# if can't login into ACR, try restarting or even re-installing Docker engine. Azure CLI ACR commands seem to use docker behind the scene.
az acr login -n $RegistryName
# push image into ACR using docker
docker push $ImageName
# list available images in ACR
az acr repository list -n $RegistryName -o table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment