LogoFreestyle

VM Configuration

Overview of all configuration options for Freestyle VMs.

When creating a VM, you can configure many aspects of its behavior and contents. This section covers all available configuration options.

Quick Reference

OptionDescriptionPage
additionalFilesAdd files to the VM filesystemFiles and Repos
gitReposClone git repositoriesFiles and Repos
systemdDefine background services and startup tasksSystemd Services
domainsMap custom domains to VM portsDomains
usersCreate Linux usersUsers and Groups
groupsCreate Linux groupsUsers and Groups
persistenceControl VM storage strategyPersistence
idleTimeoutSecondsAuto-suspend after inactivityLifecycle
rootfsSizeGbRoot filesystem sizeLifecycle
workdirDefault working directoryLifecycle
waitForReadySignalWait for VM to be fully readyLifecycle
recreateAllow automatic recreationLifecycle

Configuration Methods

Direct Configuration

Pass options directly to freestyle.vms.create():

const { vm } = await freestyle.vms.create({
  workdir: "/app",
  idleTimeoutSeconds: 600,
  additionalFiles: {
    "/app/config.json": { content: "{}" },
  },
});

Using Specs

Put configuration in a VmSpec for reuse. Use it as a snapshot layer when you want caching:

import { VmSpec } from "freestyle-sandboxes";

const spec = new VmSpec({
  workdir: "/app",
  gitRepos: [{ repo: "owner/app", path: "/app" }],
  systemd: {
    services: [
      { name: "web", mode: "service", exec: ["npm start"], workdir: "/app" },
    ],
  },
});

// Create a VM directly from the spec (no caching)
const { vm } = await freestyle.vms.create({ spec });

// Use the spec as a snapshot layer to cache it
const { vm: vm2 } = await freestyle.vms.create({ snapshot: spec });

See Specs and Snapshots for more details on caching.

Combining Both

Apply dynamic configuration on top of a spec (or a cached snapshot layer):

const { vm } = await freestyle.vms.create({
  spec, // Base configuration (not cached unless used as a snapshot)
  // Dynamic config applied on top
  additionalFiles: {
    "/app/.env": { content: `API_KEY=${process.env.API_KEY}` },
  },
  idleTimeoutSeconds: 300,
});

On this page

Freestyle AI

Documentation assistant

Experimental: AI responses may not always be accurate—please verify important details with the official documentation.

How can I help?

Ask me about Freestyle while you browse the docs.