CLI Reference
Complete reference for all devbox commands, options, and usage patterns.
Global Options
Section titled “Global Options”All commands support these global options:
--help, -h: Show help information
Core Commands
Section titled “Core Commands”devbox status
Section titled “devbox status”Show detailed container status and resource usage for a project. With no project specified, prints a quick overview of all devbox containers.
Syntax:
devbox status [project]Behavior:
- With a project: shows state, uptime, CPU%, memory usage/%, network I/O, block I/O, PIDs, ports, and mounts
- Without a project: lists all devbox containers with status and image
Examples:
# Overview of all devbox containersdevbox status
# Detailed status for a specific projectdevbox status myprojectdevbox up
Section titled “devbox up”Start a devbox environment from a shared devbox.json in the current directory. Perfect for onboarding: clone the repo and run devbox up.
Syntax:
devbox up [--dotfiles <path>] [--keep-running]Options:
--dotfiles <path>: Mount a local dotfiles directory into common locations inside the box--keep-running: Keep the box running after setup completes (overrides auto-stop-on-idle)
Behavior:
- Reads
./devbox.json - Creates/starts a box named
devbox_<name>where<name>comes fromdevbox.json’sname(or the folder name) - Applies ports, env, and volumes from configuration
- Runs a system update, then
setup_commands - Installs the devbox wrapper for nice shell UX
- Records package installations you perform inside the box to
devbox.lock(apt/pip/npm/yarn/pnpm). On rebuilds, these commands are replayed to reproduce the environment. - If global setting
auto_stop_on_exitis enabled (default),devbox upstops the container right away if it is idle (no exposed ports and only the init process running). Use--keep-runningto leave it running. - When
auto_stop_on_exitis enabled and yourdevbox.jsondoes not specify arestartpolicy, devbox uses--restart noto prevent the container from auto-restarting after being stopped.
Examples:
# Start from current folder's devbox.jsondevbox up
# Mount your dotfilesdevbox up --dotfiles ~/.dotfilesdevbox init
Section titled “devbox init”Create a new devbox project with its own Docker box (container).
Syntax:
devbox init <project> [flags]Options:
--force, -f: Force initialization, overwriting existing project--template, -t <template>: Initialize from template (python, nodejs, go, web)--generate-config, -g: Generate devbox.json configuration file--config-only, -c: Generate configuration file only (don’t create box)
Examples:
# Basic projectdevbox init myproject
# Python project with templatedevbox init python-app --template python
# Force overwrite existing projectdevbox init myproject --force
# Generate config file onlydevbox init myproject --config-only --template nodejs
# Create with custom configurationdevbox init webapp --generate-configTemplates:
python: Python 3, pip, venv, development toolsnodejs: Node.js 18, npm, build toolsgo: Go 1.21, git, build toolsweb: Python + Node.js + nginx for full-stack development
devbox shell
Section titled “devbox shell”Open an interactive bash shell in the project’s box.
Syntax:
devbox shell <project> [--keep-running]Examples:
# Enter project environmentdevbox shell myproject
# Start stopped box and enter shelldevbox shell python-appNotes:
- Automatically starts the box if stopped
- Sets working directory to
/workspace - Your project files are available at
/workspace - Exit with
exit,logout, orCtrl+D - By default, the box stops automatically after you exit the shell when global setting
auto_stop_on_exitis enabled (default) - Use
--keep-runningto keep the box running after you exit the shell
devbox run
Section titled “devbox run”Run an arbitrary command inside the project’s box.
Syntax:
devbox run <project> <command> [args...] [--keep-running]Examples:
# Run single commanddevbox run myproject python3 --version
# Run with argumentsdevbox run myproject apt install -y htop
# Complex command with pipesdevbox run myproject "cd /workspace && python3 -m http.server 8000"
# Execute scriptdevbox run myproject bash /workspace/setup.shNotes:
- Commands run in
/workspaceby default - Use quotes for complex commands with pipes, redirects, etc.
- Box starts automatically if stopped
- By default, the box stops automatically after the command finishes when global setting
auto_stop_on_exitis enabled (default) - Use
--keep-runningto keep the box running after the command finishes
devbox stop
Section titled “devbox stop”Stop a project’s box if it’s running.
Syntax:
devbox stop <project>Examples:
# Stop a running boxdevbox stop myproject
# Stop another project's boxdevbox stop webappNotes:
- Safe to run if the box is already stopped (no-op)
- Complements the default auto-stop behavior after
shellandrun
devbox destroy
Section titled “devbox destroy”Stop and remove the project’s box.
Syntax:
devbox destroy <project> [flags]Options:
--force, -f: Force destruction without confirmation
Examples:
# Destroy with confirmationdevbox destroy myproject
# Force destroy without promptdevbox destroy myproject --forceNotes:
- Preserves project files in
~/devbox/<project>/ - Box can be recreated with
devbox init - Use
rm -rf ~/devbox/<project>/to remove files
devbox list
Section titled “devbox list”Show all managed projects and their box status.
Syntax:
devbox list [flags]Options:
--verbose, -v: Show detailed information including configuration
Examples:
# Basic listdevbox list
# Detailed informationdevbox list --verboseOutput Format:
DEVBOX PROJECTSPROJECT BOX STATUS CONFIG WORKSPACE-------------------- -------------------- --------------- ------------ ------------------------------myproject devbox_myproject Up 2 hours devbox.json /home/user/devbox/myprojectwebapp devbox_webapp Exited none /home/user/devbox/webapp
Total projects: 2devbox lock
Section titled “devbox lock”Generate a comprehensive environment snapshot as devbox.lock.json for a project. This is ideal for sharing/auditing the exact box image, container configuration, and globally installed packages.
Syntax:
devbox lock <project> [-o, --output <path>]Options:
-o, --output <path>: Write the lock file to a custom path. Defaults to<workspace>/devbox.lock.json.
Behavior:
- Ensures the project’s box is running (starts it if needed).
- Inspects the container and its image to capture:
- Base image: name, digest (if available), image ID
- Container config: working_dir, user, restart policy, network, ports, volumes, labels, environment, capabilities, resources (cpus/memory)
- Installed package snapshots:
- apt: manually installed packages pinned as
name=version - pip:
pip freezeoutput - npm/yarn/pnpm: globally installed packages as
name@version(Yarn global versions are detected from Yarn’s global dir)
- apt: manually installed packages pinned as
- Registries and sources for reproducibility:
- pip:
index-urlandextra-index-url - npm/yarn/pnpm: global registry URLs
- apt:
sources.listlines, snapshot base URL if present, and OS release codename
- pip:
- If
devbox.jsonexists in the workspace, includes itssetup_commandsfor context.
This snapshot is meant for sharing and audit. It does not currently drive devbox up automatically; continue to use devbox.json plus the simple devbox.lock command list for replay. A future devbox restore may apply devbox.lock.json directly.
Examples:
# Write snapshot into the project workspacedevbox lock myproject
# Write snapshot to a custom filedevbox lock myproject -o ./env/devbox.lock.jsonSample Output (excerpt):
{ "version": 1, "project": "myproject", "box_name": "devbox_myproject", "created_at": "2025-09-18T20:41:51Z", "base_image": { "name": "ubuntu:22.04", "digest": "ubuntu@sha256:...", "id": "sha256:..." }, "container": { "working_dir": "/workspace", "user": "root", "restart": "no", "network": "bridge", "ports": ["3000/tcp -> 0.0.0.0:3000"], "volumes": ["bind /host/path -> /workspace (rw=true)"], "environment": {"TZ": "UTC"}, "labels": {"devbox.project": "myproject"}, "capabilities": ["SYS_PTRACE"], "resources": {"cpus": "2", "memory": "2048MB"} }, "packages": { "apt": ["git=1:2.34.1-..."], "pip": ["requests==2.32.3"], "npm": ["typescript@5.6.2"], "yarn": ["eslint@9.1.0"], "pnpm": [] }, "registries": { "pip_index_url": "https://pypi.org/simple", "pip_extra_index_urls": ["https://mirror.example/simple"], "npm_registry": "https://registry.npmjs.org/", "yarn_registry": "https://registry.yarnpkg.com", "pnpm_registry": "https://registry.npmjs.org/" }, "apt_sources": { "snapshot_url": "https://snapshot.debian.org/archive/debian/20240915T000000Z/", "sources_lists": [ "deb https://snapshot.debian.org/archive/debian/20240915T000000Z/ bullseye main" ], "pinned_release": "jammy" }, "setup_commands": [ "apt install -y python3 python3-pip" ]}devbox verify
Section titled “devbox verify”Validate that the running box matches the devbox.lock.json exactly. Fails fast on any drift.
Syntax:
devbox verify <project>Checks:
- Package sets: apt, pip, npm, yarn, pnpm (exact set match)
- Registries: pip index/extra-index, npm/yarn/pnpm registry URLs
- Apt sources: sources.list lines, snapshot base URL (if present), OS release codename
Returns non-zero on any mismatch and prints a concise drift report.
Example:
devbox verify myprojectdevbox apply
Section titled “devbox apply”Apply the devbox.lock.json to the running box: configure registries and apt sources, then reconcile package sets to match the lock.
Syntax:
devbox apply <project>Behavior:
- Registries:
- Writes
/etc/pip.confwithindex-url/extra-index-urlfrom lock - Runs
npm/yarn/pnpmconfig to set global registry URLs
- Writes
- Apt sources:
- Backs up and rewrites
/etc/apt/sources.list, clears/etc/apt/sources.list.d/*.list - Optionally sets a default release hint, then
apt update
- Backs up and rewrites
- Reconciliation:
- APT: install exact versions from lock, remove extras, autoremove
- Pip: install missing exact versions, uninstall extras
- npm/yarn/pnpm (global): add missing exact versions, remove extras
Exits non-zero if application fails at any step.
Example:
devbox apply myprojectConfiguration Commands
Section titled “Configuration Commands”devbox templates
Section titled “devbox templates”Manage devbox project templates (built-in and user-defined).
Subcommands:
devbox templates list
Section titled “devbox templates list”List available templates (built-in + user templates in ~/.devbox/templates).
Syntax:
devbox templates listdevbox templates show
Section titled “devbox templates show”Show a template’s JSON (name, description, and config).
Syntax:
devbox templates show <name>devbox templates create
Section titled “devbox templates create”Create devbox.json in the current directory from a template.
Syntax:
devbox templates create <name> [project]Examples:
cd ~/devbox/myappdevbox templates create python MyApp
# If project name omitted, folder name is useddevbox templates create nodejsdevbox templates save
Section titled “devbox templates save”Save the current folder’s devbox.json as a reusable user template in ~/.devbox/templates/<name>.json.
Syntax:
devbox templates save <name>devbox templates delete
Section titled “devbox templates delete”Delete a user template by name.
Syntax:
devbox templates delete <name>devbox config
Section titled “devbox config”Manage devbox configurations.
Subcommands:
devbox config generate
Section titled “devbox config generate”Generate devbox.json configuration file for a project.
Syntax:
devbox config generate <project> [flags]Options:
--template, -t <template>: Use template configuration
Examples:
# Generate basic configdevbox config generate myproject
# Generate with templatedevbox config generate myproject --template pythondevbox config validate
Section titled “devbox config validate”Validate project configuration file.
Syntax:
devbox config validate <project>devbox config show
Section titled “devbox config show”Display project configuration details.
Syntax:
devbox config show <project>Note: Template listing and management has moved to the top-level devbox templates command.
devbox config global
Section titled “devbox config global”Show global devbox configuration.
Syntax:
devbox config globalMaintenance Commands
Section titled “Maintenance Commands”devbox version
Section titled “devbox version”Display the version information for devbox.
Syntax:
devbox versionExamples:
# Display version informationdevbox versionOutput Format:
devbox (v1.0)devbox cleanup
Section titled “devbox cleanup”Clean up Docker resources and devbox artifacts.
Syntax:
devbox cleanup [flags]Options:
--orphaned: Remove orphaned containers only--images: Remove unused images only--volumes: Remove unused volumes only--networks: Remove unused networks only--system-prune: Run docker system prune--all: Clean up everything--dry-run: Show what would be cleaned (no changes)--force: Skip confirmation prompts
Examples:
# Interactive cleanup menudevbox cleanup
# Clean specific resourcesdevbox cleanup --orphaneddevbox cleanup --images
# Comprehensive cleanupdevbox cleanup --all
# Preview cleanup actionsdevbox cleanup --dry-run --all
# Cleanup without promptsdevbox cleanup --all --forcedevbox maintenance
Section titled “devbox maintenance”Perform maintenance tasks on devbox projects and boxes.
Syntax:
devbox maintenance [flags]Options:
--status: Show detailed system status--health-check: Check health of all projects--update: Update all boxes--restart: Restart stopped boxes--rebuild: Rebuild all boxes--auto-repair: Auto-fix common issues--force: Skip confirmation prompts
Examples:
# Interactive maintenance menudevbox maintenance
# Individual tasksdevbox maintenance --health-checkdevbox maintenance --updatedevbox maintenance --restart
# Combined operationsdevbox maintenance --health-check --update --restart
# Auto-repair issuesdevbox maintenance --auto-repair
# Force operations without promptsdevbox maintenance --force --rebuilddevbox update
Section titled “devbox update”Pull the latest base image(s) and rebuild environment box(es).
This command replaces boxes to ensure they are based on the newest upstream images, while preserving your workspace files on the host.
Syntax:
devbox update [project]Behavior:
- When a project is specified, only that environment is updated
- With no project, all registered projects are updated
- Pulls the latest base image, recreates the box with current devbox.json config, and re-runs setup commands
- Replays package install commands from
devbox.lockto restore your previously installed packages
Options:
- None currently. Uses your existing configuration in
devbox.jsonif present.
Examples:
# Update a single projectdevbox update myproject
# Update all projectsdevbox updateNotes:
- Your files remain in ~/devbox/
/ and are re-mounted into the new box - If the project has a devbox.json, its settings (ports, env, volumes, etc.) are applied on rebuild
- System packages inside the box are updated as part of the rebuild
- If the box exists, it will be stopped and replaced; if missing, it will be created
Exit Codes
Section titled “Exit Codes”Devbox uses standard exit codes:
0: Success1: General error2: Invalid arguments or usage125: Docker daemon not running126: Container not executable127: Container/command not found
Environment Variables
Section titled “Environment Variables”Devbox respects these environment variables:
DOCKER_HOST: Docker daemon socketDEVBOX_HOME: Override default~/.devboxdirectoryDEVBOX_WORKSPACE: Override default~/devboxworkspace directory
Project Structure
Section titled “Project Structure”When you create a project, devbox sets up:
~/devbox/<project>/ # Project workspace (host)├── devbox.json # Configuration file (optional)├── your-files... # Your project files└── ...
~/.devbox/ # Global configuration├── config.json # Global settings and project registry└── ...Inside Box:
/workspace/ # Mounted from ~/devbox/<project>/├── devbox.json # Same files as host├── your-files...└── ...Shell Completion
Section titled “Shell Completion”devbox completion
Section titled “devbox completion”Generate completion scripts for your shell to enable tab autocompletion for devbox commands, flags, project names, and template names.
Syntax:
devbox completion [bash|zsh|fish]Supported Shells:
- Bash: Autocompletion for commands, flags, project names, and templates (Linux)
- Zsh: Full autocompletion with descriptions (Linux)
- Fish: Intelligent completion with suggestions (Linux)
Setup Instructions:
Bash:
# Load completion for current sessionsource <(devbox completion bash)
# Install for all sessions (Linux)sudo devbox completion bash > /etc/bash_completion.d/devboxZsh:
# Enable completion if not already enabledecho "autoload -U compinit; compinit" >> ~/.zshrc
# Install for all sessionsdevbox completion zsh > "${fpath[1]}/_devbox"
# Restart your shell or source ~/.zshrcFish:
# Load completion for current sessiondevbox completion fish | source
# Install for all sessionsdevbox completion fish > ~/.config/fish/completions/devbox.fishWhat Gets Completed:
- Command names (
init,shell,run,list, etc.) - Command flags (
--template,--force,--keep-running) - Project names for commands like
shell,run,stop,destroy - Template names for
--templateflag andtemplates show/delete
Examples:
# Tab completion examples (press TAB after typing)devbox <TAB> # Shows: init, shell, run, list, etc.devbox shell <TAB> # Shows: your-project-namesdevbox init myapp --template <TAB> # Shows: python, nodejs, go, webdevbox templates show <TAB> # Shows: available-template-namesDocker Integration
Section titled “Docker Integration”Devbox creates boxes (Docker containers) with these characteristics:
- Name:
devbox_<project> - Base Image:
ubuntu:22.04(configurable) - Working Directory:
/workspace - Mount:
~/devbox/<project>→/workspace - Restart Policy:
unless-stopped(ornowhenauto_stop_on_exitis enabled and no explicit policy is set) - Command:
sleep infinity(keeps box alive)
Docker Commands Equivalent:
# devbox init myprojectdocker create --name devbox_myproject \ --restart unless-stopped \ -v ~/devbox/myproject:/workspace \ -w /workspace \ ubuntu:22.04 sleep infinity
# devbox shell myprojectdocker start devbox_myprojectdocker exec -it devbox_myproject bash
# devbox run myproject <command>docker exec devbox_myproject <command>
# devbox destroy myprojectdocker stop devbox_myprojectdocker rm devbox_myproject