Automatically collect and manage logs from all running Docker containers in your GitHub Actions workflow.
- Automatic Log Collection: Gather logs from all running Docker containers
- Flexible Output: Stream to stdout or save to files for artifact upload
- Selective Filtering: Target specific containers by image name
- Configurable Limits: Control log volume with line count limits
- Cross-Shell Support: Works with different shell environments
- Easy Integration: Simple YAML configuration for any workflow
Add this action to your workflow to automatically collect Docker logs on failure:
- name: Collect Docker logs on failure
if: failure()
uses: step-security/gh-docker-logs@v2| Parameter | Description | Default | Required |
|---|---|---|---|
dest |
Destination folder to write log files. If not provided, logs are written to stdout. Files are named by container (e.g., redis.log) |
stdout | No |
images |
Comma-delimited list of image names to filter containers. Supports exact matches (mongo:3.4.22) or name-only matches (mongo) |
all containers | No |
tail |
Maximum number of lines to collect from each container | all |
No |
shell |
Shell to execute commands | /bin/sh |
No |
- stdout mode: Logs are printed directly to the workflow output
- file mode: Individual log files are created for each container in the specified directory
- filtering: Only containers matching the specified images are processed
- naming: Log files use container names with
.logextension
- name: Collect Docker logs on failure
if: failure()
uses: step-security/gh-docker-logs@v2- name: Collect specific service logs
uses: step-security/gh-docker-logs@v2
with:
images: 'redis,mongo,postgres'
tail: '100'- name: Collect Docker logs to files
if: failure()
uses: step-security/gh-docker-logs@v2
with:
dest: './docker-logs'
- name: Archive logs
if: failure()
run: tar -czf docker-logs.tar.gz ./docker-logs
- name: Upload logs as artifact
if: failure()
uses: actions/upload-artifact@v4
with:
name: docker-logs
path: docker-logs.tar.gz
retention-days: 7- name: Collect logs with custom shell
if: failure()
uses: step-security/gh-docker-logs@v2
with:
shell: '/bin/bash'- Use with
if: failure()to avoid unnecessary log collection on successful runs - Set appropriate
taillimits for large applications to prevent overwhelming output - Filter by specific images when you only need logs from certain services
- Upload logs as artifacts for persistent access to debugging information
- Consider log retention policies when using artifact uploads
- CI/CD Debugging: Capture logs when tests fail
- Integration Testing: Monitor service interactions
- Performance Analysis: Collect logs for performance troubleshooting
- Security Auditing: Preserve container output for security reviews
This project is licensed under the MIT License - see the LICENSE file for details.