Hi @hashim-abu-gellban_3562,
Due to some reasons I don't fully understand, authenticating to the Docker API requires using a Bearer authentication token Authorization: Bearer {token}
Here is an example for how to get that token:
function GetDockerToken() {
param (
[string] $packageName = $(throw "-packageName is required. This is the namespace and image name. For example: library/my-container-image"),
[string] $feed = $(throw "-feed is required"),
[string] $actionToAuthorize = $(throw "-action is required. This is the docker action to be authorized (pull, push, delete, etc)"),
[string] $apiKey = $(throw "-apiKey is required"),
[string] $progetBaseUrl = $(throw "-progetBaseUrl is required. "),
[string] $service
)
if ($service -eq "") {
# This expects that $progetBaseUrl is prepended with "https://" If you are using "http://" then change 8 to 7 below.
$service = $progetBaseUrl.SubString(8,$progetBaseUrl.Length-8)
}
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "api","$apiKey")))
$response = Invoke-WebRequest -Uri "$progetBaseUrl/v2/_auth?service=$service&scope=repository`:$feed/$packageName`:$actionToAuthorize" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
if ($response.StatusDescription -eq "OK") {
$token = ($response.Content | ConvertFrom-Json).token
$token
}
}
I know we plan to document all this better some day, for now you can find the Semantic Versioning for Containers page.
Dean