DoMD includes a powerful command testing system that can validate and test shell commands in isolated Docker containers. This helps ensure that commands work as expected across different environments.
- Command Validation: Automatically detect valid shell commands and filter out documentation, logs, and other non-command text
- Docker Testing: Test commands in isolated Docker containers to verify they work as expected
- Automatic .doignore Updates: Automatically update
.doignorewith commands that fail in Docker - CLI & REST API: Full support for both command-line and programmatic access
# Test individual commands
domd test-commands "ls -la" "pwd" "echo Hello"
# Test commands from a file
domd test-commands -f commands.txt
# Test commands and update .doignore
domd test-commands --update-doignore -f commands.txt
# Skip Docker testing (only validate commands)
domd test-commands --no-docker -f commands.txt
# Specify custom .dodocker and .doignore paths
domd test-commands --dodocker custom.dodocker --doignore .customignore -f commands.txt-f, --file: Read commands from a file (one per line)--update-doignore: Update .doignore with commands that fail in Docker--dodocker: Path to .dodocker configuration file (default: .dodocker)--doignore: Path to .doignore file (default: .doignore)--no-docker: Skip Docker testing and only validate commands-v, --verbose: Enable verbose output
POST /api/commands/validate
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"commands": ["ls -la", "pwd", "echo Hello"],
"test_in_docker": true,
"update_doignore": true
}POST /api/commands/test-docker
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"commands": ["ls -la", "pwd", "echo Hello"],
"update_doignore": true
}POST /api/commands/ignore
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"commands": ["invalid_command"],
"comment": "These commands don't work in our environment"
}The .dodocker file specifies how commands should be executed in Docker. Here's an example:
# Run Python commands in Python container
python:
image: python:3.9-slim
description: Python interpreter
workdir: /app
# Run Node.js commands in Node container
node:
image: node:16
description: Node.js runtime
workdir: /app
volumes:
./:/app
# Commands with specific requirements
"npm install":
image: node:16
description: Install Node.js dependencies
workdir: /app
volumes:
./:/app
~/.npm:/root/.npm- Start with validation: Use
--no-dockerfirst to validate commands before Docker testing - Update .doignore: Regularly update
.doignorewith commands that are known to fail - Customize .dodocker: Create specific configurations for different types of commands
- Use in CI: Integrate command testing into your CI/CD pipeline to catch issues early
-
Docker not available:
- Ensure Docker is installed and running
- Run
docker psto verify Docker is working
-
Permission denied:
- Run with
sudoor add your user to thedockergroup sudo usermod -aG docker $USER
- Run with
-
Command not found in container:
- Update the container image in
.dodockerto include required tools - Use a more complete base image like
ubuntu:latestfor testing
- Update the container image in
-
Network issues:
- Ensure the container has network access if commands need to download files
- Add
--network hostto Docker run options in.dodockerif needed