Portainer 2 NATIVE Templates

Convert Portainer 1.x Templates to be Portainer 2.0 NATIVE Templates

In OpenMediaVault, Tutorials, Video by dbtech

In this video we’re going to look at how to convert Portainer 1.x templates to be Portainer 2.0 NATIVE Templates.

With the release of Portainer 2.0 out, some changes have come with it that affect how we can use Application Templates. At first, there was rumor that 2.0 wouldn’t support templates at all, but then I found out via Reddit, that Portainer 2 supports templates, but the templates from version 1 have to be converted to a new format.

In this post we’re going to look at how to convert your favorite 1.x templates to work with Portainer 2.0.

Finding a v1 Template

First things first, we need to find a template that we want to work in 2.0. I’m going to use the SelfHostedPro template that I first talked about in this video.

Here is the template.json file we’re going to use:

https://raw.githubusercontent.com/SelfhostedPro/selfhosted_templates/master/Template/template.json

Converting to V2

We’re going to do a Select-All and Copy.

Next, we’ll open our SSH program and login to our server. Once you’re logged in, navigate to /tmp and enter the following command:

nano templates.json

This should bring up an empty terminal screen. Click somewhere in the screen and then RIGHT-Click to paste your clipboard. It should paste everything from the template.json we copied from Github earlier.

Now you can press CTRL-O and CTRL-X to save and exit.

You’ll now run this command to start up a temporary container built by Portainer that will convert the 1.x template to a 2.x template:

docker run --rm -v /tmp/templates.json:/src/templates.json -v /tmp/output:/dist portainer/helper-templates

If this is successful, you should see an output like this:

2020/08/26 00:51:27 New template file successfully created at /dist/templates-upgraded.json

Something to note is that you HAVE to be in the /tmp directory and your file HAS to be named templates.json

Now you can FTP into your server (I use WinSCP for this) and navigate to /tmp/output to download your templates-upgraded.json file.

You’ll need to store this somewhere online that you can access remotely. I stored mine on Github here:

https://raw.githubusercontent.com/dnburgess/self-hosted-template/master/template.json

You can copy and paste that URL into your portainer application templates text field and now use Portainer 2.0 NATIVE Templates.