06 February 2019

Get all Docker images available for Business Central

You can use below PowerShell script to get all the Docker images available for Business Central. This is very useful if you always work with Docker Containers and want to test your changes with different localizations and different builds. 

If you are still new to docker then its better to read my previous blog post about the Docker and containers before jumping into the script. 
 $ResultingObject = @()  
 $result = Invoke-WebRequest -Uri "https://registry.hub.docker.com/v2/repositories/microsoft/bcsandbox/tags/?page_size=250"   
 $JsonObject = ConvertFrom-Json -InputObject $result.Content  
 $ResultingObject = $JsonObject.results  
 $ParentId = 1  
 while ($JsonObject.next) {  
   $result = Invoke-WebRequest -Uri $JsonObject.next   
   $JsonObject = ConvertFrom-Json -InputObject $result.Content  
   $ResultingObject += $JsonObject.results    
   $percCompleted = [Math]::Round($ResultingObject.Count / $JsonObject.count, 4) * 100  
   Write-Progress -Activity "Processing tags" -PercentComplete $percCompleted -ParentId $ParentId   
 }  
 $ResultingObject.Count  
 #Display all tags:  
 $ResultingObject.name  

If you want to filter the result you can use below code. In this example, it will filter the Docker images which belong to the W1 version. 
  #All W1 tags:   
  $ResultingObject | where name -like ‘*-w1*’ | select name   

Thank you Waldo for the script. Please refer original blog post if you need more information. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara

No comments:

Post a Comment