Playwright Testing Environment
Modern browser testing with Playwright and trace viewer.
Overview
Playwright is Microsoft's modern end-to-end testing framework that enables reliable testing across Chromium, Firefox, and WebKit browsers with a single API. Released in 2020, it addresses common browser automation challenges with features like auto-wait, network interception, and comprehensive debugging tools including trace generation for test analysis. This deployment creates a complete testing environment with two specialized services: a Playwright test runner container with all browser engines pre-installed, and a dedicated trace viewer service using NGINX to serve test results and debugging traces through a web interface. The configuration is designed for development teams and QA engineers who need a containerized testing environment with visual debugging capabilities. The trace-viewer service provides immediate access to test reports at http://localhost:8080/report and trace files for debugging at http://localhost:8080/traces, making it valuable for teams that need to analyze test failures, share debugging information, or integrate browser testing into CI/CD pipelines with persistent result storage.
Key Features
- Multi-browser support with Chromium, Firefox, and WebKit engines pre-installed in a single container
- Web-based trace viewer accessible at port 8080 for visual test debugging and analysis
- Persistent test results and reports storage using Docker volumes for result retention
- Network isolation between Playwright runner and trace viewer for secure test execution
- Ready-to-mount test directory structure with ./tests mapped to container workspace
- NGINX-powered static file serving for fast access to generated HTML reports and trace files
- Keep-alive Playwright container for interactive test development and debugging sessions
- Separate read-only volume mounts for traces and reports to prevent accidental data modification
Common Use Cases
- 1Development teams running cross-browser compatibility tests with visual debugging capabilities
- 2CI/CD pipelines requiring persistent test result storage and web-accessible reporting
- 3QA engineers analyzing test failures through Playwright's trace viewer interface
- 4Remote teams sharing test execution traces and reports through centralized web access
- 5Educational environments teaching browser automation with hands-on trace analysis
- 6Automated testing workflows that need to archive and review historical test results
- 7Development workflows requiring isolated browser testing without local browser installations
Prerequisites
- Docker Engine 20.10+ with support for multi-platform images (Playwright image is Linux-based)
- Minimum 4GB RAM available for Docker (Playwright browsers are memory-intensive during execution)
- Port 8080 available on host system for accessing the trace viewer web interface
- Test files prepared in ./tests directory structure compatible with Playwright test discovery
- Basic understanding of Playwright test syntax and trace file generation commands
- Network connectivity for initial image pulls (Playwright image is approximately 2GB)
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 playwright: 3 image: mcr.microsoft.com/playwright:latest4 working_dir: /app5 volumes: 6 - ./tests:/app7 - playwright_results:/app/test-results8 - playwright_reports:/app/playwright-report9 command: tail -f /dev/null10 networks: 11 - playwright_net1213 trace-viewer: 14 image: nginx:alpine15 ports: 16 - "8080:80"17 volumes: 18 - playwright_results:/usr/share/nginx/html/traces:ro19 - playwright_reports:/usr/share/nginx/html/report:ro20 networks: 21 - playwright_net2223volumes: 24 playwright_results: 25 playwright_reports: 2627networks: 28 playwright_net: .env Template
.env
1# Playwright2# Run tests: docker compose exec playwright npx playwright test3# Reports at http://localhost:8080/report4# Traces at http://localhost:8080/tracesUsage Notes
- 1Run tests in playwright container
- 2Reports at http://localhost:8080/report
- 3Trace files at http://localhost:8080/traces
- 4Chromium, Firefox, WebKit included
- 5Use npx playwright show-trace for viewer
Individual Services(2 services)
Copy individual services to mix and match with your existing compose files.
playwright
playwright:
image: mcr.microsoft.com/playwright:latest
working_dir: /app
volumes:
- ./tests:/app
- playwright_results:/app/test-results
- playwright_reports:/app/playwright-report
command: tail -f /dev/null
networks:
- playwright_net
trace-viewer
trace-viewer:
image: nginx:alpine
ports:
- "8080:80"
volumes:
- playwright_results:/usr/share/nginx/html/traces:ro
- playwright_reports:/usr/share/nginx/html/report:ro
networks:
- playwright_net
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 playwright:5 image: mcr.microsoft.com/playwright:latest6 working_dir: /app7 volumes:8 - ./tests:/app9 - playwright_results:/app/test-results10 - playwright_reports:/app/playwright-report11 command: tail -f /dev/null12 networks:13 - playwright_net1415 trace-viewer:16 image: nginx:alpine17 ports:18 - "8080:80"19 volumes:20 - playwright_results:/usr/share/nginx/html/traces:ro21 - playwright_reports:/usr/share/nginx/html/report:ro22 networks:23 - playwright_net2425volumes:26 playwright_results:27 playwright_reports:2829networks:30 playwright_net:31EOF3233# 2. Create the .env file34cat > .env << 'EOF'35# Playwright36# Run tests: docker compose exec playwright npx playwright test37# Reports at http://localhost:8080/report38# Traces at http://localhost:8080/traces39EOF4041# 3. Start the services42docker compose up -d4344# 4. View logs45docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/playwright-testing/run | bashTroubleshooting
- Browser crashes with 'GPU process launch failed': Add --disable-gpu and --no-sandbox flags to browser launch options in test configuration
- Trace viewer shows 404 for report files: Ensure tests generate reports with correct output directory matching the mounted volume paths
- Playwright container exits immediately: The tail -f /dev/null command keeps container running - use docker exec to access for test execution
- Cannot access trace viewer at localhost:8080: Check if port 8080 is already in use and verify trace-viewer service started successfully
- Test results not persisting between container restarts: Verify playwright_results and playwright_reports volumes are properly mounted and accessible
- Fonts rendering incorrectly in screenshots: Install additional font packages in Playwright container or use headless mode with font fallbacks
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Ad Space
Shortcuts: C CopyF FavoriteD Download