Skip to content
Docs

DevContainer CLI

The DevContainer CLI lets you build and run CodeForge containers without VS Code. Use it when you prefer terminal-only workflows, work on headless servers, or need DevContainer support in CI/CD pipelines.

Terminal window
npm install -g @devcontainers/cli

Requires Node.js 16.13+ or 18+ (when installing via npm). Verify the installation with devcontainer --version.

From your project root (where .devcontainer/ lives):

Terminal window
devcontainer up --workspace-folder .

The first build takes several minutes — it pulls the base image, installs all features, and runs post-start setup. Subsequent starts reuse cached layers and complete in seconds.

The recommended way to get a shell inside the container:

Terminal window
devcontainer exec --workspace-folder . zsh

This uses the devcontainer CLI’s exec command, which respects the container’s configured user and environment. You can also use docker exec directly — run docker ps to find the container name:

Terminal window
docker exec -it <container-name> zsh

Execute commands without entering an interactive shell:

Terminal window
# Run check-setup to verify the installation
devcontainer exec --workspace-folder . check-setup
# Launch a Claude Code session
devcontainer exec --workspace-folder . cc
# List installed tools
devcontainer exec --workspace-folder . cc-tools

VS Code auto-forwards container ports to your host automatically. The CLI does not. You need an explicit forwarding mechanism.

Recommended: Install devcontainer-bridge (dbr) for dynamic, automatic port forwarding that works with any terminal client. CodeForge pre-installs the container side — you only need the host daemon:

Terminal window
# On your host machine
dbr host-daemon

Alternative: Use SSH tunneling for specific ports:

Terminal window
ssh -L 7847:localhost:7847 <container-user>@<container-host>

See Port Forwarding for the full setup guide and comparison of all forwarding mechanisms.

CapabilityVS CodeDevContainer CLI
Port forwardingAutomaticManual — use dbr or SSH tunneling
Extensions panelGUI in sidebarNot available
Ports panelVisual port managementNot available — use docker port or dbr
Terminal managementIntegrated tabsManual — use tmux for parallel sessions
File editingBuilt-in editorUse your preferred editor (vim, nano, etc.)

When you change devcontainer.json or feature configurations, rebuild:

Terminal window
# Rebuild using cached layers (fast)
devcontainer up --workspace-folder .
# Full rebuild from scratch (slow, but fixes cache issues)
devcontainer up --workspace-folder . --remove-existing-container

The devcontainer CLI doesn’t have a dedicated stop command. Use Docker directly:

Terminal window
# Find the container name
docker ps
# Stop the container
docker stop <container-name>
# Or stop and remove it
docker rm -f <container-name>
  • Use tmux for parallel sessions inside the container. CodeForge installs tmux by default — run tmux after connecting to get split panes and persistent sessions.
  • Connect external terminals using the scripts in .codeforge/scripts/connect-external-terminal.sh (macOS/Linux) or connect-external-terminal.ps1 (Windows PowerShell).
  • Combine with dbr for the closest experience to VS Code — automatic port forwarding without needing VS Code running.