Manuals / Playwright with Python / Chapter 36

Part 5 · CI/CD & Reporting · advanced · ~40 min · Chapter 36 of 61

27. Dockerizing Playwright Tests

Official Playwright Docker image Microsoft publishes a pre-built image with browsers and all system dependencies already installed, avoiding "works on my machine" issues caused by missing OS libraries. docker run -it --rm mcr.microsoft.com/playwright/python:v1.48.0-jammy /bin/bash Pointers: The version tag (v1.48.0 here) should match your installed playwright pip package version — a mismatch betwe

Path progress
58%

Step 1 of 5

Official Playwright Docker image

Microsoft publishes a pre-built image with browsers and all system dependencies already installed, avoiding "works on my machine" issues caused by missing OS libraries. Pointers: The version tag (v1.48.0 here) should match your installed playwright Python package's expected protocol version can cause obscure failures, so pin both deliberately rather than always pulling :latest.

Official Playwright Docker imageDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →Page under testdrag · tap →Multi-browserdrag · tap →Automation pathdrag · tap →Tooling nodedrag · tap →

Try it

Run / study this snippet

docker run -it --rm mcr.microsoft.com/playwright/python:v1.48.0-jammy /bin/bash
Was this step clear?
Chapter learning outcomes
  • Official Playwright Docker image
  • WORKDIR /app
  • RUN pip install -r requirements.txt
  • FROM <image>
  • WORKDIR, COPY, RUN, CMD (standard Dockerfile instructions)

Clear these before you leave

Side quest

27. Dockerizing Playwright Tests deliverable

Apply one idea from “Official Playwright Docker image” in a small script or note.