Docker provides an isolated environment for running Playwright MCP, which is recommended for production deployments and security-sensitive scenarios.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/microsoft/playwright-mcp/llms.txt
Use this file to discover all available pages before exploring further.
The Docker implementation currently only supports headless Chromium.
Spawned Container Mode
In this mode, the MCP client spawns a new Docker container for each session.Configuration Options
-i: Interactive mode (required for STDIO communication)--rm: Automatically remove container when it exits--init: Use an init process to handle signals properly--pull=always: Always pull the latest image before running
Long-Lived Service Mode
For better performance and resource management, you can run the container as a long-lived service instead of letting the MCP client spawn it.Starting the Service
Configuration
-d: Run in detached mode--name playwright: Name the container for easier management-p 8931:8931: Map port 8931 to host--host 0.0.0.0: Bind to all interfaces inside the container--no-sandbox: Required in most Docker environments
Client Configuration
Configure your MCP client to connect to the HTTP endpoint:Building Custom Docker Image
You can build the Docker image yourself for customization or local development.Clone and Build
Dockerfile Overview
The Dockerfile uses a multi-stage build:Docker Compose
For more complex deployments, use Docker Compose:docker-compose.yml
Start with Docker Compose
Environment Variables
Pass environment variables to configure the server:Volume Mounts
Output Directory
Mount a volume to persist output files:Configuration File
Mount a configuration file:Security Considerations
Best Practices
Run as non-root
The official image runs as the
node user for security.Use isolated mode
Enable
--isolated to prevent persistent state between sessions.Restrict network access
Use Docker networks and firewalls to limit container connectivity.
Limit resources
Use Docker resource constraints (
--memory, --cpus) to prevent resource exhaustion.Troubleshooting
Container exits immediately
Ensure you’re using-i (interactive) flag for STDIO mode or properly configuring HTTP mode with --port and --host 0.0.0.0.
Connection refused
Verify that:- The container is running:
docker ps - Port mapping is correct:
-p 8931:8931 - Server is bound to
0.0.0.0notlocalhost - Firewall allows the connection
Browser crashes
Add--no-sandbox flag (required in most Docker environments) and ensure sufficient memory is available.
