How it works
At a high level, a template build works like this:- Resolve the template source such as a standard base image, an existing image, a Dockerfile, or another template.
- Apply template instructions such as
runCmd,copy,makeDir,setEnvs, and package-install helpers. - If configured, start the template start command.
- Wait until the ready command succeeds.
- Save the prepared environment as a reusable template.
templateId / template_id and a buildId / build_id. Use the template ID later with Sandbox.create(...).
User and workdir
Templates can set the default Linux user and working directory used by later build steps and by the final environment. UsesetUser(...) / set_user(...) when build commands must run as a specific user. Use setWorkdir(...) / set_workdir(...) when later commands and copied files should resolve relative to a specific directory.
Caching
Template builds cache previously completed layers so repeated builds do not have to rerun every instruction. This is usually what you want for fast iteration. When you need a fully fresh build, disable cache for the whole build withskipCache: true / skip_cache=True, or mark the template chain with skipCache() / skip_cache().