CI/CDINTERMEDIATE

Running Playwright in Docker: The Reliable Way

Use Microsoft's official Playwright Docker image to eliminate 'works on my machine' failures across local, CI, and Kubernetes.

iff Solution Academy July 1, 2026 9 min read Updated July 1, 2026
Playwright Docker CI

Why Docker?

Playwright ships an official image with browsers and system dependencies pre-installed — perfect for consistent CI, Kubernetes jobs, or debugging OS-specific flakes.

A Working Dockerfile

Dockerfile
FROM mcr.microsoft.com/playwright:v1.47.0-jammy
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["npx", "playwright", "test"]

docker-compose for Local Runs

docker-compose.yml
services:
  e2e:
    build: .
    ipc: host
    volumes:
      - ./playwright-report:/app/playwright-report
    environment:
      - BASE_URL=http://host.docker.internal:3000

Gotchas

  • Always set ipc: host — Chromium needs it to avoid crashes.
  • Pin the Playwright image version to match your @playwright/test version exactly.
  • Use --network host on Linux to reach services on the host machine.

Get Playwright tutorials in your inbox

Weekly tips, real-world examples, and framework patterns – no spam, unsubscribe anytime.

Recommended Next Articles