Today, I was prepping for my 2-day Masterclass about developing Extensions in Visual Studio Code. And finally, I made some time to make a first version of a function that I have been wanting for quite some time: a function to remove all the custom apps from a docker image.
What is the challenge?
Well, if you’re used to Extensions V1 – then you’ll notice things have changed on many levels :-). Let’s just say that it’s darn difficult to loose your data. And in my case here – I want to do exactly that. I want to completely clean my custom apps from the Docker container, including data.
By default, when you uninstall or unpublish the app, the data will not be removed. It will simply stay there in the companion tables or dedicated tables for the App – waiting for you to reinstall the app, or upgrade the app.
Why would I want to remove the data?
Well, just imagine development scenarios, where you are working on multiple apps (dependent or not) on one system, and you want to start from scratch again.
Or – in my case – when preparing for demos, and you want to – again – start from a clean sheet.
Or …
OK, show me how!
Well, as said, finally I made some time to put it into a function. And for your convenience, I already put it on my github, you can find it here.
And you see it’s simple. It assumes you’re already using the navcontainerhelper – which you should use when using NAV on Docker (in my opinion). More info on Freddy’s blog.
It is going to search for all apps which are not Microsoft’s apps, loop them, and uninstall, clean and unpublish all these apps one-by-one.. .
You can simply call this function like:
Clean-CustomNAVAppsOnDocker -ContainerName navserver
Are there other ways?
Well, you could obviously just ignore this entire blogpost, and simple replace the docker container by re-installing it. But in this case, you might lose data that you might depend on, or settings, or accessibility, or … .
If Docker still looks a little bit like this to you:
You might just want to reconsider re-installing the container, and just go for the function I talked about ;-).
2 comments
You have probably chosen the picture of the Rena randomly but it took us a while here in New Zealand to get these containers sorted. A script would have been nice :-). Thanks for sharing yours
Author
It was indeed completely at random – nice picture though ;-).
Thanks for the comments!