AI EngineerGuide

How to use Apple Container for Mastra Agent Sandbox

by Ashik Nesin Ashik Nesin

Apple’s container which is a lightweight OCI-compatible virtual machine optimized for Apple silicon running on macOS 26+.

Mastra Agent has first class support for it.

How to get started?

npm install @mastra/apple-container
# Make sure you've installed it
container system start

And a sample code snippet from Mastra docs

import { Agent } from '@mastra/core/agent'
import { Workspace } from '@mastra/core/workspace'
import { AppleContainerSandbox } from '@mastra/apple-container'

const workspace = new Workspace({
  sandbox: new AppleContainerSandbox({
    image: 'node:22-slim',
    volumes: {
      '/Users/me/project': '/workspace',
    },
    workingDir: '/workspace',
  }),
})

const agent = new Agent({
  id: 'dev-agent',
  name: 'Dev Agent',
  instructions: 'You are a coding assistant working in this workspace.',
  model: 'anthropic/claude-sonnet-4-6',
  workspace,
})

const response = await agent.generate('Run `node --version`.')
console.log(response.text)

Reference

Stay Updated

Get the latest AI engineering insights delivered to your inbox.

No spam. Unsubscribe at any time.