Skip to main content

Overview

Container templates let you create custom environments by layering your base Docker image with in10nt agent infrastructure.
Container templates create custom Docker images. For cloning existing instances with their workspace/files, use instances.createFromTemplate() instead

Create Template

Create a custom environment from a Docker image:
const template = await client.templates.create({
  name: 'python-ml',              // Required: Human-readable name
  description: 'Python ML env',   // Optional: Description
  image: 'python:3.11-slim',      // Required: Base Docker image
  registryType: 'dockerhub',      // Required: dockerhub | private | gcr
  registryAuth: {                 // Optional: For private registries
    username: 'user',
    password: 'pass'
  }
});

console.log(`Template ID: ${template.templateId}`);
console.log(`Status: ${template.status}`); // "building"

Parameters

ParameterTypeRequiredDescription
namestringYesHuman-readable template name
imagestringYesBase Docker image (e.g., python:3.11-slim)
registryTypestringYesRegistry type: dockerhub, private, or gcr
descriptionstringNoTemplate description
registryAuthobjectNoAuthentication for private registries

Registry Types

  • dockerhub: Public Docker Hub images
  • private: Private Docker registries
  • gcr: Google Container Registry

Response

{
  templateId: "tmpl_1704588123456",
  name: "python-ml",
  image: "python:3.11-slim",
  status: "building",  // building → ready | failed
  createdAt: "2025-01-06T..."
}

Wait Until Ready

Wait for template to finish building:
const template = await client.templates.create({
  name: 'ml-env',
  image: 'nvidia/cuda:12.2-runtime',
  registryType: 'dockerhub'
});

await template.waitUntilReady({
  timeout: 300000,      // 5 minutes (default)
  pollInterval: 5000    // Check every 5 seconds (default)
});

console.log(`Ready! Platform image: ${template.platformImage}`);

Options

OptionTypeDefaultDescription
timeoutnumber300000Maximum wait time in ms
pollIntervalnumber5000Polling interval in ms

List Templates

Get all your templates:
const templates = await client.templates.list();

templates.forEach(template => {
  console.log(`${template.name}: ${template.status}`);
});

Get Template Status

Check template build status:
const template = await client.templates.get('tmpl_1704588123456');

console.log(`Status: ${template.status}`);
if (template.status === 'failed') {
  console.error(`Error: ${template.error}`);
}

Status Values

  • building: Template is being built
  • ready: Template is ready to use
  • failed: Build failed (check error field)

Delete Template

Delete a template:
await template.delete();
Or by ID:
const template = await client.templates.get('tmpl_123');
await template.delete();

Use Template with Instance

Once a template is ready, use it to create instances:
// Create and wait for template
const template = await client.templates.create({
  name: 'ml-env',
  image: 'python:3.11-slim',
  registryType: 'dockerhub'
});

await template.waitUntilReady();

// Create instance with template
const instance = await client.instances.create({
  name: 'ml-agent',
  templateId: template.templateId
});

const result = await instance.run('Train a classifier on data.csv');

Private Registry Authentication

For private registries, provide authentication:
const template = await client.templates.create({
  name: 'private-env',
  image: 'registry.example.com/myimage:latest',
  registryType: 'private',
  registryAuth: {
    username: process.env.REGISTRY_USER,
    password: process.env.REGISTRY_PASS
  }
});
Never hardcode registry credentials. Use environment variables or secret management

Common Use Cases

Python ML Environment

const mlTemplate = await client.templates.create({
  name: 'python-ml',
  image: 'python:3.11-slim',
  registryType: 'dockerhub',
  description: 'Python with ML libraries'
});

await mlTemplate.waitUntilReady();

Node.js Development

const nodeTemplate = await client.templates.create({
  name: 'node-dev',
  image: 'node:20-alpine',
  registryType: 'dockerhub',
  description: 'Node.js 20 development'
});

await nodeTemplate.waitUntilReady();

CUDA/GPU Environment

const gpuTemplate = await client.templates.create({
  name: 'cuda-env',
  image: 'nvidia/cuda:12.2-runtime',
  registryType: 'dockerhub',
  description: 'NVIDIA CUDA 12.2'
});

await gpuTemplate.waitUntilReady();

Error Handling

try {
  const template = await client.templates.create({
    name: 'my-env',
    image: 'python:3.11-slim',
    registryType: 'dockerhub'
  });
  
  await template.waitUntilReady({ timeout: 300000 });
  
} catch (error) {
  if (error.message.includes('Template build failed')) {
    console.error('Build failed - check image and credentials');
  } else if (error.message.includes('timeout')) {
    console.error('Build took too long');
  } else {
    console.error('Unexpected error:', error.message);
  }
}

Template vs Instance Cloning

FeatureContainer TemplatesInstance Cloning
What it doesLayers base Docker image with agent infrastructureClones existing instance workspace
Use caseCustom base environments (Python, Node, etc.)Reuse configured workspaces
Methodclient.templates.create()client.instances.createFromTemplate()
Build time2-5 minutesInstant
Files includedOnly base image filesAll workspace files