There are two types of Portainer templates:
- type
stack: the new type that uses Docker stack under the hood and is better to use on Portainer - type
container: the old type that can only start one container, discouraged to use except if thestacktype is too limited (e.g. old DB2 and old MSSQL server containers need more priviliges that only thecontainertype can provide)
A stack type template consists of two things:
- a YAML file in the Docker stack format that contains definitions like which container(s) to start on which ports, by our convention always named
docker-stack.yml(to avoid confusion with Docker Compose) - an entry in the
new-stack-templates.jsonthat includes some metadata about the template and makes the Docker stack YAML file available in Portainer UI
To create a new one:
- In the
stacksdirectory create a new subdirectory with the name of your stack (please follow existing naming scheme) and create a newdocker-stack.ymlinside that subdirectory or duplicate an existing subdirectory and modify the includeddocker-stack.ymlwith different Docker image or ports etc. - Edit the file
new-stack-templates.jsonto create or duplicate an entry and supply metadata as required, minimum is changedtitleanddescriptionfields (for Portainer UI) and the correct path instackfilefield! - Run
python3 generate-stack-templates.pyto regenerate thestack-templates.jsonwhich is the definitive file consumed by Portainer - Create a new branch (e.g. use JIRA issue number), check in all modified/new files e.g. via
git add . - Push the new commit and open a Pull Request
- When the PR is merged it may take some minutes for the change to be available in Portainer UI (due to Github caching)
- Modify a
docker-stack.ymlor the filenew-stack-templates.jsonas needed - Run
python3 generate-stack-templates.pyto regenerate thestack-templates.jsonwhich is the definitive file consumed by Portainer - Create a new branch (e.g. use JIRA issue number), check in all modified/new files e.g. via
git add . - Push the new commit and open a Pull Request
- When the PR is merged it may take some minutes for the change to be available in Portainer UI (due to Github caching)
A container type template consists only of an entry in the templates.json that includes some metadata about the template
and the docker image to run.
To create a new one:
- Edit the file
templates.jsonto create an entry for the new template. You can check the file for how the changes should look like. - Run
python3 generate-stack-templates.pyto regenerate thestack-templates.jsonwhich is the definitive file consumed by Portainer - Create a new branch (e.g. use JIRA issue number), check in all modified/new files e.g. via
git add . - Push the new commit and open a Pull Request
- When the PR is merged it may take some minutes for the change to be available in Portainer UI (due to Github caching)