|
| 1 | +# Docker Logging Configuration Fix |
| 2 | + |
| 3 | +## Issue Description |
| 4 | + |
| 5 | +The Docker containers created by the SWE Factory tool were using a logging configuration that disabled container logs: |
| 6 | + |
| 7 | +```json |
| 8 | +"ContainerIDFile": "", |
| 9 | +"LogConfig": { |
| 10 | + "Type": "none", |
| 11 | + "Config": {} |
| 12 | +} |
| 13 | +``` |
| 14 | + |
| 15 | +This configuration meant: |
| 16 | +- No container logs were being captured |
| 17 | +- `docker logs <container>` would not work |
| 18 | +- Debugging container issues was difficult |
| 19 | +- The tool couldn't capture container output for analysis |
| 20 | + |
| 21 | +## Root Cause |
| 22 | + |
| 23 | +The issue was in the container creation code in two files: |
| 24 | +1. `app/agents/test_analysis_agent/docker_utils.py` - `build_container()` function |
| 25 | +2. `evaluation/docker_build.py` - `build_container()` and `build_setup_container()` functions |
| 26 | + |
| 27 | +These functions were creating containers without explicit logging configuration, causing Docker to use default settings that might be set to `"none"` in some environments. |
| 28 | + |
| 29 | +## Solution Applied |
| 30 | + |
| 31 | +I've updated all container creation calls to include proper logging configuration: |
| 32 | + |
| 33 | +### Before: |
| 34 | +```python |
| 35 | +container = client.containers.create( |
| 36 | + image=test_image_name, |
| 37 | + name=test_container_name, |
| 38 | + user="root", |
| 39 | + detach=True, |
| 40 | + command="tail -f /dev/null", |
| 41 | + nano_cpus=None, |
| 42 | + platform="linux/x86_64", |
| 43 | +) |
| 44 | +``` |
| 45 | + |
| 46 | +### After: |
| 47 | +```python |
| 48 | +container = client.containers.create( |
| 49 | + image=test_image_name, |
| 50 | + name=test_container_name, |
| 51 | + user="root", |
| 52 | + detach=True, |
| 53 | + command="tail -f /dev/null", |
| 54 | + nano_cpus=None, |
| 55 | + platform="linux/x86_64", |
| 56 | + log_config={ |
| 57 | + "Type": "json-file", |
| 58 | + "Config": { |
| 59 | + "max-size": "10m", |
| 60 | + "max-file": "3" |
| 61 | + } |
| 62 | + } |
| 63 | +) |
| 64 | +``` |
| 65 | + |
| 66 | +## Benefits of the Fix |
| 67 | + |
| 68 | +1. **Container Logs Available**: You can now use `docker logs <container>` to view container output |
| 69 | +2. **Better Debugging**: Container issues can be diagnosed more easily |
| 70 | +3. **Log Rotation**: Logs are automatically rotated when they reach 10MB |
| 71 | +4. **Storage Management**: Only 3 log files are kept per container |
| 72 | +5. **Tool Functionality**: The SWE Factory tool can now capture and analyze container output |
| 73 | + |
| 74 | +## Files Modified |
| 75 | + |
| 76 | +1. `app/agents/test_analysis_agent/docker_utils.py` - Line 330-340 |
| 77 | +2. `evaluation/docker_build.py` - Lines 590-600 and 650-660 |
| 78 | + |
| 79 | +## Testing the Fix |
| 80 | + |
| 81 | +After applying this fix, you should be able to: |
| 82 | + |
| 83 | +1. Run the SWE Factory tool as usual |
| 84 | +2. Use `docker logs <container_name>` to view container logs |
| 85 | +3. See container output in the tool's log files |
| 86 | +4. Debug container issues more effectively |
| 87 | + |
| 88 | +## Recommended Docker Configuration |
| 89 | + |
| 90 | +For optimal performance, ensure your Docker daemon is configured with: |
| 91 | + |
| 92 | +```json |
| 93 | +{ |
| 94 | + "log-driver": "json-file", |
| 95 | + "log-opts": { |
| 96 | + "max-size": "10m", |
| 97 | + "max-file": "3" |
| 98 | + } |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +This ensures consistent logging behavior across all containers, even those created without explicit logging configuration. |
0 commit comments