When to Use
Useisol8 cleanup to:
- Remove orphaned containers — Clean up containers left behind from interrupted executions or persistent sessions
- Free disk space — Remove stopped containers that are no longer needed
- Reset environment — Clear all isol8 containers before starting fresh
- Maintenance — Periodic cleanup as part of system maintenance routines
Container Detection
The command identifies isol8 containers by their image names:- Containers using images starting with
isol8:(base images) - Containers using images starting with
isol8-custom:(custom images with baked-in packages)
Options
Skip the interactive confirmation prompt and remove all containers immediately. Useful for automation and scripts.
Interactive Mode (Default)
By default, the command displays all found containers and prompts for confirmation before removal:Container Status Icons
- 🟢 running — Container is currently executing code
- ⚪ stopped — Container has exited and is no longer running
Force Mode
Use--force to skip the confirmation prompt. This is useful in automated scripts or CI/CD pipelines:
Return Codes
| Code | Meaning |
|---|---|
0 | Success — all containers removed or no containers found |
1 | Error — Docker not running, connection failed, or permission denied |
0 but displays a warning with the failure count.
Examples
Basic Cleanup
Scheduled Cleanup
You can manually configure cron to run cleanup periodically. isol8 does not automatically install or manage cron jobs — you need to set this up yourself. Example cron entry for daily cleanup at 2 AM:Before Running Tests
Clean up before running integration tests:Programmatic Usage
For programmatic cleanup in TypeScript/JavaScript applications, use the staticDockerIsol8.cleanup() method:
Automatic Cleanup
Note that theisol8 serve command includes automatic cleanup of stale persistent sessions when cleanup.autoPrune is enabled in the configuration. The server checks for idle sessions every 60 seconds and removes those that exceed cleanup.maxContainerAgeMs. This is different from the manual isol8 cleanup command, which removes ALL isol8 containers regardless of age or state.
Safety
Theisol8 cleanup command is safe to run at any time:
- Container selection — Only removes containers with isol8-specific images. Your other Docker containers are never touched.
- Force removal — Uses
docker rm --forceto remove containers even if they’re running. Code execution is immediately terminated. - No data loss — Containers use ephemeral tmpfs storage by design. No persistent data is lost.
- Idempotent — Safe to run multiple times. If no containers exist, the command exits gracefully with an info message.
Troubleshooting
Docker Not Running
Permission Denied
sudo or to add your user to the docker group:
Container Removal Failed
If some containers fail to remove:- Check if containers are in use by another process
- Try stopping the container first:
docker stop <container-id> - Use Docker’s native removal:
docker rm --force <container-id> - If persistent errors occur, restart the Docker daemon
Related Commands
isol8 run— Execute code in isol8 containersisol8 config— View cleanup configuration (auto-prune, max age)isol8 serve— Start server with automatic stale session cleanup