Docker Runner - amosproj/amos2025ss04-ai-driven-testing GitHub Wiki
A tool for running Docker containers sequentially with input/output handling
Overview
Sequential Docker Runner is a Python utility that executes Docker containers in sequence, ensuring only one container runs at a time. It sends input to each container, captures output, and performs thorough cleanup after execution.
Installation
No installation required. Simply download the script and ensure Python 3.6+ and Docker are installed.
Requirements
- Python 3.6+
- Docker installed and running
- Standard Python libraries
Configuration
Edit the CONTAINERS
list in the script to specify which containers to run:
CONTAINERS = [
["container-image:tag", "input data for container"],
# Add more containers as needed
]
Usage
Run the script from command line:
python3 sequential_docker_runner.py
The script will:
- Run containers in sequence
- Provide input and collect output
- Ensure no two containers run simultaneously
- Continue running until terminated
To quit: Press q
followed by Enter
Features
- Sequential Execution: Ensures only one container runs at any time
- Input/Output Handling: Provides data to containers and captures results
- Automatic Cleanup: Verifies containers are removed after execution
- Continuous Operation: Runs containers in loops until stopped
- Graceful Termination: Clean shutdown when requested
Implementation Details
- Each container receives a unique name with prefix
sequential-runner-
- Multiple verification steps ensure no containers remain after execution
- Uses threading for monitoring user input without blocking container operations
- Comprehensive logging to console and docker_runner.log
Error Handling
- Detects and removes containers from previous runs
- Force-removes containers that fail to stop normally
- Performs cleanup even on unexpected termination
Note: This script is designed to handle containers that can accept stdin input and produce output. Adjust the container command if your use case is different.