Jack Wallen shows you how to create custom templates in Portainer to make your container development process more efficient.
Portainer has become my go-to for managing container deployments. This one-stop-shop makes building apps and services incredibly easy and supports nearly every step required for deploying complete, containerized apps.
One of the features included by Portainer is the ability to create custom app templates. With these app templates, you can create reusable manifests for full-stack apps. Think of it as your way to create, save, and use dockerfiles over and over again – all from the Portainer GUI. Using custom templates is a great way to simplify your workflow and lighten your development load.
SEE: Recruitment kit: Back-end developer (TechRepublic Premium)
What you will need
To work with custom templates, you will need a running instance of Portainer and an account to log in with. And that’s it: let’s get to work.
How to create a custom template
Login to Portainer
Point your web browser to your Portainer instance and log in with a user account that has permissions to create various assets on the platform.
Access the Custom Templates section
Click to expand the App Templates section in the left sidebar, then click Custom Templates (Figure A).
Create the new model
In the top section of the add custom template page (Figure C), give the template a name – such as nextcloud-template – and a description.
Be sure to select Linux as the platform and, if available, select Swarm in the type. Once you’ve taken care of that, scroll down to the Build Method section. Paste the following content into the Web Editor section (Figure D). Be sure to change passwords to be strong and unique:
Scroll down and click Create Custom Template to save your work.
How to deploy the model
We can now use our model again and again. In the Custom Template section (Figure E), click on the newly created custom template.
In the resulting window (Figure F), give the stack a unique name and click Deploy Stack.
After a while, the stacked containers will be ready for use.
You can reuse this custom template as often as you want. One thing to keep in mind, however, is that if you reuse it while a previous deployment is running, you’ll need to change the external port number for Nextcloud, otherwise it won’t work because the port in the template is already in use.
And that’s all there is to creating and using custom templates in Portainer. Take advantage of this newfound efficiency.
How to learn more about Docker
If you want to learn more about Docker, don’t miss these resources from the TechRepublic Academy:
Subscribe to TechRepublic How to make technology work on YouTube for all the latest tech tips for professionals from Jack Wallen.