check_alias_exists
client- Authenticated API clientalias- Template alias to check
assign_tags
client- Authenticated API clienttarget_name- Template name in ‘name:tag’ format (the source build to tag from)tags- Tags to assign
remove_tags
client- Authenticated API clientname- Template nametags- List of tags to remove
get_template_tags
client- Authenticated API clienttemplate_id_or_name- Template ID or name (a name may be namespaced)
Template
build
template: The template to buildname: Template name in ‘name’ or ‘name:tag’ formatalias: (Deprecated) Alias name for the template. Use name instead.tags: Optional additional tags to assign to the templatecpu_count: Number of CPUs allocated to the sandbox.memory_mb: Amount of memory in MB allocated to the sandbox.min_free_disk_mb: Requested minimum free space after the build steps, in MiB. Growth is best effort and the filesystem is never shrunk. Omit to use the team default or set to 0 to request no growth.skip_cache: If True, forces a complete rebuild ignoring cacheon_build_logs: Callback function to receive build logs during the build process Example
build_in_background
template: The template to buildname: Template name in ‘name’ or ‘name:tag’ formatalias: (Deprecated) Alias name for the template. Use name instead.tags: Optional additional tags to assign to the templatecpu_count: Number of CPUs allocated to the sandbox.memory_mb: Amount of memory in MB allocated to the sandbox.min_free_disk_mb: Requested minimum free space after the build steps, in MiB. Growth is best effort and the filesystem is never shrunk. Omit to use the team default or set to 0 to request no growth.skip_cache: If True, forces a complete rebuild ignoring cache
get_build_status
build_info: Build identifiers returned from build_in_backgroundlogs_offset: Offset for fetching logs; when omitted, the API default applies
exists
name: Template name to check
alias_exists
exists instead.
Arguments:
alias: Template alias to check
assign_tags
target_name: Template name in ‘name:tag’ format (the source build to tag from)tags: Tag or tags to assign
remove_tags
name: Template nametags: Tag or tags to remove Example
get_tags
template_id: Template ID or name
__init__
file_context_path: Base path for resolving relative file paths in copy operationsfile_ignore_patterns: Patterns in.dockerignoresyntax for files to exclude when copying. They are applied after the.dockerignorefile in the context directory, so they take precedence over it. An invalid pattern (such as an unterminated[) raises a :class:TemplateException. Brace expansion ({a,b}) is not supported, as in Docker
skip_cache
TemplateBase class
Example
from_debian_image
variant: Debian image variant
TemplateBuilder class
Example
from_ubuntu_image
variant: Ubuntu image variant (default: ‘latest’)
TemplateBuilder class
Example
from_fedora_image
variant: Fedora image variant (default: ‘44’)
TemplateBuilder class
Example
from_alpine_image
variant: Alpine image variant (default: ‘3.24’)
TemplateBuilder class
Example
from_arch_image
latest: Arch is a rolling release and template
provisioning runs pacman -Syu, so pinning a tag would not change
the built result.
Arguments:
variant: Arch Linux image variant (default: ‘latest’)
TemplateBuilder class
Example
from_python_image
version: Python version (default: ‘3’)
TemplateBuilder class
Example
from_node_image
variant: Node.js image variant (default: ‘lts’)
TemplateBuilder class
Example
from_bun_image
variant: Bun image variant (default: ‘latest’)
TemplateBuilder class
from_base_image
TemplateBuilder class
Example
from_image
image: Docker image name (e.g., ‘ubuntu:24.04’)username: Username for private registry authenticationpassword: Password for private registry authentication
TemplateBuilder class
Example
from_template
template: E2B template ID or alias
TemplateBuilder class
Example
from_dockerfile
dockerfile_content_or_path: Either the Dockerfile content as a string, or a path to a Dockerfile file
TemplateBuilder class
Example
from_aws_registry
image: Docker image name from AWS ECRaccess_key_id: AWS access key IDsecret_access_key: AWS secret access keyregion: AWS region
TemplateBuilder class
Example
from_gcp_registry
image: Docker image name from GCP registryservice_account_json: Service account JSON string, dict, or path to JSON file
TemplateBuilder class
Example
to_json
template: The template to convert (TemplateBuilder or TemplateFinal instance)
to_dockerfile
template: The template to convert (TemplateBuilder or TemplateFinal instance)
ValueError: If the template is based on another E2B template or has no base image Example