Represents an image definition for a Daytona sandbox.
Do not construct this class directly. Instead use one of its static factory methods,
such as Image.base(), Image.debianSlim() or Image.fromDockerfile().
Accessors
Section titled “Accessors”contextList
Section titled “contextList”Get Signature
Section titled “Get Signature”get contextList(): Context[];Returns
Section titled “Returns”Context[]
The list of context files to be added to the image.
dockerfile
Section titled “dockerfile”Get Signature
Section titled “Get Signature”get dockerfile(): string;Returns:
string- The Dockerfile content.
Methods
Section titled “Methods”base()
Section titled “base()”static base(image: string): Image;Creates an Image from an existing base image.
Parameters:
imagestring - The base image to use.
Returns:
Image- The Image instance.
Example:
const image = Image.base('python:3.12-slim-bookworm')debianSlim()
Section titled “debianSlim()”static debianSlim(pythonVersion?: "3.9" | "3.10" | "3.11" | "3.12" | "3.13"): Image;Creates a Debian slim image based on the official Python Docker image.
Parameters:
pythonVersion?“3.9” | “3.10” | “3.11” | “3.12” | “3.13” - The Python version to use.
Returns:
Image- The Image instance.
Example:
const image = Image.debianSlim('3.12')fromDockerfile()
Section titled “fromDockerfile()”static fromDockerfile(path: string): Image;Creates an Image from an existing Dockerfile.
Parameters:
pathstring - The path to the Dockerfile.
Returns:
Image- The Image instance.
Example:
const image = Image.fromDockerfile('Dockerfile')addLocalDir()
Section titled “addLocalDir()”addLocalDir(localPath: string, remotePath: string): Image;Adds a local directory to the image.
Parameters:
localPathstring - The path to the local directory.remotePathstring - The path of the directory in the image.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .addLocalDir('src', '/home/daytona/src')addLocalFile()
Section titled “addLocalFile()”addLocalFile(localPath: string, remotePath: string): Image;Adds a local file to the image.
Parameters:
localPathstring - The path to the local file.remotePathstring - The path of the file in the image.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .addLocalFile('requirements.txt', '/home/daytona/requirements.txt')cmd(cmd: string[]): Image;Sets the default command for the image.
Parameters:
cmdstring[] - The command to set as the default command.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .cmd(['/bin/bash'])dockerfileCommands()
Section titled “dockerfileCommands()”dockerfileCommands(dockerfileCommands: string[], contextDir?: string): Image;Extends an image with arbitrary Dockerfile-like commands.
Parameters:
dockerfileCommandsstring[] - The commands to add to the Dockerfile.contextDir?string - The path to the context directory.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .dockerfileCommands(['RUN echo "Hello, world!"'])entrypoint()
Section titled “entrypoint()”entrypoint(entrypointCommands: string[]): Image;Sets the entrypoint for the image.
Parameters:
entrypointCommandsstring[] - The commands to set as the entrypoint.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .entrypoint(['/bin/bash'])env(envVars: Record<string, string>): Image;Sets environment variables in the image.
Parameters:
envVarsRecord<string, string> - The environment variables to set.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .env({ FOO: 'bar' })pipInstall()
Section titled “pipInstall()”pipInstall(packages: string | string[], options?: PipInstallOptions): Image;Adds commands to install packages using pip.
Parameters:
packagesstring | string[] - The packages to install.options?PipInstallOptions - The options for the pip install command.
Returns:
Image- The Image instance.
Example:
const image = Image.debianSlim('3.12').pipInstall('numpy', { findLinks: ['https://pypi.org/simple'] })pipInstallFromPyproject()
Section titled “pipInstallFromPyproject()”pipInstallFromPyproject(pyprojectToml: string, options?: PyprojectOptions): Image;Installs dependencies from a pyproject.toml file.
Parameters:
pyprojectTomlstring - The path to the pyproject.toml file.options?PyprojectOptions - The options for the pip install command.
Returns:
Image- The Image instance.
Example:
const image = Image.debianSlim('3.12')image.pipInstallFromPyproject('pyproject.toml', { optionalDependencies: ['dev'] })pipInstallFromRequirements()
Section titled “pipInstallFromRequirements()”pipInstallFromRequirements(requirementsTxt: string, options?: PipInstallOptions): Image;Installs dependencies from a requirements.txt file.
Parameters:
requirementsTxtstring - The path to the requirements.txt file.options?PipInstallOptions - The options for the pip install command.
Returns:
Image- The Image instance.
Example:
const image = Image.debianSlim('3.12')image.pipInstallFromRequirements('requirements.txt', { findLinks: ['https://pypi.org/simple'] })runCommands()
Section titled “runCommands()”runCommands(...commands: (string | string[])[]): Image;Runs commands in the image.
Parameters:
commands…(string | string[])[] - The commands to run.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .runCommands( 'echo "Hello, world!"', ['bash', '-c', 'echo Hello, world, again!'] )workdir()
Section titled “workdir()”workdir(dirPath: string): Image;Sets the working directory in the image.
Parameters:
dirPathstring - The path to the working directory.
Returns:
Image- The Image instance.
Example:
const image = Image .debianSlim('3.12') .workdir('/home/daytona')Context
Section titled “Context”Represents a context file to be added to the image.
Properties:
archivePathstring - The path inside the archive file in object storage.sourcePathstring - The path to the source file or directory.
PipInstallOptions
Section titled “PipInstallOptions”Options for the pip install command.
Properties:
extraIndexUrls?string[] - The extra index URLs to use for the pip install command.extraOptions?string - The extra options to use for the pip install command. Given string is passed directly to the pip install command.findLinks?string[] - The find-links to use for the pip install command.indexUrl?string - The index URL to use for the pip install command.pre?boolean - Whether to install pre-release versions.
Extended by
Section titled “Extended by”PyprojectOptions
PyprojectOptions
Section titled “PyprojectOptions”Options for the pip install command from a pyproject.toml file.
Properties:
extraIndexUrls?string[] - The extra index URLs to use for the pip install command.- Inherited from:
PipInstallOptions.extraIndexUrls
- Inherited from:
extraOptions?string - The extra options to use for the pip install command. Given string is passed directly to the pip install command.- Inherited from:
PipInstallOptions.extraOptions
- Inherited from:
findLinks?string[] - The find-links to use for the pip install command.- Inherited from:
PipInstallOptions.findLinks
- Inherited from:
indexUrl?string - The index URL to use for the pip install command.- Inherited from:
PipInstallOptions.indexUrl
- Inherited from:
optionalDependencies?string[] - The optional dependencies to install.pre?boolean - Whether to install pre-release versions.- Inherited from:
PipInstallOptions.pre
- Inherited from:
Extends:
PipInstallOptions