Skip to content

Container Lifecycle

RAPID manages dev container lifecycle through simple commands. This document explains how containers are started, managed, and stopped.

Containers move through these states:

StateDescription
Not CreatedNo container exists
BuildingContainer image being built
RunningContainer active and ready
StoppedContainer exists but not running

Transitions:

  • rapid start → Building → Running
  • rapid stop → Stopped
  • rapid stop --remove → Not Created

Starts the development environment:

Terminal window
rapid start [options]

Options:

OptionDescription
--rebuildForce rebuild the container image
--no-cacheBuild without Docker cache
--reinstall-toolsReinstall AI CLI tools
--skip-secretsSkip secret loading
-d, --detachRun in background

What it does:

  1. Reads configuration from rapid.json and devcontainer.json 2. Builds container image (if needed) 3. Starts container with devcontainer up 4. Loads secrets from 1Password/Vault 5. Installs missing AI CLI tools 6. Generates/updates instruction files 7. Configures MCP servers

Launches an AI coding session:

Terminal window
rapid dev [options]

Options:

OptionDescription
--agent <name>Use specific agent (overrides default)
--multiLaunch all configured agents
--attachAttach to existing session

What it does:

  1. Verifies container is running (starts if autoStart: true) 2. Attaches to container 3. Launches configured AI CLI 4. Manages session for multi-agent mode

Stops the development environment:

Terminal window
rapid stop [options]

Options:

OptionDescription
--removeRemove container after stopping
--volumesAlso remove volumes
--forceForce stop (SIGKILL)

RAPID integrates with devcontainer lifecycle hooks:

devcontainer.json
{
"initializeCommand": "rapid hooks initialize",
"onCreateCommand": "rapid hooks onCreate",
"postCreateCommand": "rapid hooks postCreate",
"postStartCommand": "rapid hooks postStart"
}
HookWhenActions
initializeCommandOn host, before buildValidate config, pre-fetch secrets
onCreateCommandFirst time onlyInstall system dependencies
postCreateCommandFirst time onlyInstall AI tools, generate files
postStartCommandEvery startLoad secrets, update files
{
"container": {
"devcontainer": ".devcontainer/devcontainer.json",
"compose": null,
"autoStart": true,
"buildArgs": {
"NODE_VERSION": "20"
}
}
}

RAPID uses but does not modify devcontainer.json:

ConcernConfigured In
Base imagedevcontainer.json
System packagesdevcontainer.json
VS Code extensionsdevcontainer.json
Port forwardingdevcontainer.json
AI agentsrapid.json
Secretsrapid.json
Context filesrapid.json
MCP serversrapid.json

For multi-container setups:

{
"container": {
"compose": "docker-compose.yml",
"service": "app"
}
}

RAPID will:

  1. Start all services in the compose file
  2. Attach to the specified service for AI sessions

By default, devcontainers mount the project directory:

{
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}"
}

For data that should persist across rebuilds:

{
"mounts": ["source=rapid-cache,target=/home/vscode/.cache,type=volume"]
}
Terminal window
# Check Docker is running
docker info
# View container logs
docker logs <container-id>
# Rebuild from scratch
rapid start --rebuild --no-cache

Enable VirtioFS in Docker Desktop settings for better file system performance.

Terminal window
# Fix ownership (in container)
sudo chown -R vscode:vscode /workspaces
Terminal window
# Reinstall tools
rapid start --reinstall-tools
  1. Use devcontainer features for common tools
  2. Keep images small — Install only what’s needed
  3. Use volumes for caches (npm, pip, etc.)
  4. Don’t store secrets in the container image
  5. Rebuild periodically to get security updates