Retrieving NAV Docker images from the registry API

It can be very handy to know which NAV Docker images are available on Microsoft’s public Docker repository, you can either do this the boring way by browsing¬†this website (it will only show the 100? most recent tags) or the cool way by using (obviously) PowerShell.

For the latter we need to use the Docker Registry HTTP API, I thought this would be very simple since the registry is publicly accessible, but guess what?
That’s not really the case through the API…

To make your life a little easier, I’ve created two PowerShell functions and two simple helper functions to forget about this hassle.
Let’s start with the helper functions!

No need to show the code for this one, it just returns the static docker repository name (microsoft/dynamics-nav)

This function will authenticate against the Docker registry and ask for permissions to pull from this repository, in the response we will get an access token which we can use in the other API calls.

And now the actual functions…

This function will authenticate against the Docker registry by using the Get-AuthorizationHeader helper function and retrieve an array of all the available Docker image tags.
Those tags are not the fully qualified image names so I add the repository name in front of it (microsoft/dynamics-nav) so they can be directly used for pulling a certain image.

This function will take an image name from the pipeline, call the Get-NavDockerImage function to retrieve all the available images and then check if the provided image name exists.
If so, it will return true, otherwise false, just like any other PowerShell function containing the ‘Test’ verb.

I’ve wrapped these four functions in a simple module you can get from my GitHub, I might also make a pull request on the NavContainerHelper to include those because that’s the place where they belong.

Leave a Reply

Your email address will not be published. Required fields are marked *