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 thestack
type is too limited (e.g. old DB2 and old MSSQL server containers need more priviliges that only thecontainer
type 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.json
that includes some metadata about the template and makes the Docker stack YAML file available in Portainer UI
To create a new one:
- In the
stacks
directory create a new subdirectory with the name of your stack (please follow existing naming scheme) and create a newdocker-stack.yml
inside that subdirectory or duplicate an existing subdirectory and modify the includeddocker-stack.yml
with different Docker image or ports etc. - Edit the file
new-stack-templates.json
to create or duplicate an entry and supply metadata as required, minimum is changedtitle
anddescription
fields (for Portainer UI) and the correct path instackfile
field! - Run
python3 generate-stack-templates.py
to regenerate thestack-templates.json
which 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.yml
or the filenew-stack-templates.json
as needed - Run
python3 generate-stack-templates.py
to regenerate thestack-templates.json
which 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.json
to create an entry for the new template. You can check the file for how the changes should look like. - Run
python3 generate-stack-templates.py
to regenerate thestack-templates.json
which 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)