Skip to main content

Overview

Templates are Docker containers images paired with a configuration.

They are used to launch images as Pods, define the required container disk size, volume, volume paths, and ports needed.

You can also define environment variables within the Template.

Template types

There a few types of Templates:

  • Managed by RunPod: Also known as offical Templates; these templates are created and maintained by RunPod.
  • Custom Templates:
    • Community Templates: Custom Templates shared by the community.
    • Private Templates: Custom Templates created by you or if using a team account, shared inside your team.

Custom Templates

Customizing Container Start Command

You can customize the Docker command to run additional commands or modify the default behavior.

The Docker command is specified in the Container Start Command field.

Default Docker Command

The default Docker command is:

bash -c '/start.sh'

This command runs the /start.sh script at the end of the container startup process.

You can customize the Docker command to run additional commands or modify the default behavior.

For example, you can add a command to run before /start.sh:

bash -c 'mkdir /testdir1 && /start.sh'

This command creates a directory /testdir1 before running /start.sh.

Using the entrypoint Field

You can also specify a JSON string with cmd and entrypoint as the keys.

The entrypoint field allows you to specify a command to run at the beginning of the container startup process. For example:

{ "cmd": ["echo foo && /start.sh"], "entrypoint": ["bash", "-c"] }

This command runs the echo command and then runs /start.sh.

Important Considerations

When using the entrypoint field, be aware that the command will run twice: once as the entrypoint and again as part of the cmd field.

This can cause issues if the command errors when run a second time. For example:

{ "cmd": ["mkdir /testdir11 && /start.sh"], "entrypoint": ["bash", "-c"] }

This command will run mkdir twice, which can cause errors if the directory already exists.

Tips and Examples

Here are some working examples to try in dev:

  • Command only: bash -c 'mkdir /testdir1 && /start.sh'
  • Command only: {"cmd": ["bash", "-c", "mkdir /testdir8 && /start.sh"]}
  • Command and Entrypoint: {"cmd": ["test-echo-test-echo"], "entrypoint": ["echo"]}
  • Cmmand and Entrypoint: {"cmd": ["mkdir -p /testdir12 && /start.sh"], "entrypoint": ["bash", "-c"]}
note

Remember to use mkdir -p to avoid errors when creating directories.