Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To run Playwright tests in Docker, install the Playwright .NET package in your test project, build the project, then install the matching browser binaries and operating-system dependencies in the container. The simplest alternative is to base a test container on the official Playwright .NET image; it already contains browsers and system dependencies, but you still need the project’s Playwright package. In either setup, keep the package and image versions aligned.

Choose how the container will get browsers

There are two practical routes. Use the official Playwright .NET image when you want a ready-made browser environment for a test job. Use a custom .NET image when you need control over the base image or want to install only the browser your tests use. Neither route replaces adding the Playwright NuGet package to the project.

Approach What the image provides Best fit Main consideration
Official Playwright .NET image Playwright browser binaries and their system dependencies CI test containers and development Add the matching Playwright package to your project; pin a versioned image tag.
Custom .NET image Only what you install in the Docker build Teams needing base-image control or a narrower browser set Build the project before running its generated Playwright install script, and ensure browser files and native libraries are available at runtime.

The official image is intended for testing and development, not as a general production web-server base. The Playwright .NET Docker documentation describes its contents, supported options, and security considerations.

Add Playwright to the .NET test project

Install Playwright in the project that launches the browser—typically a test project, rather than the ASP.NET application project. For example, from the solution directory:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
dotnet add tests/MyApp.Tests/MyApp.Tests.csproj package Microsoft.Playwright
dotnet restore
dotnet build tests/MyApp.Tests/MyApp.Tests.csproj -c Release

Replace tests/MyApp.Tests/MyApp.Tests.csproj with your actual project path. Pin the package to the version your project has selected, and use that same Playwright version for the browser image when using the official image. The package supplies the .NET API and generates a Playwright CLI script during build; it does not, by itself, put browser binaries in the container.

After building, the generated script is under the build output for the test project. For a Release build targeting a framework such as net8.0, its path is commonly shaped like bin/Release/net8.0/playwright.ps1. Use the target framework and configuration actually produced by your project; do not copy that example path blindly. The Playwright .NET installation guide documents the generated-script workflow.

Option 1: Use the official Playwright .NET image

For a CI test job, select a versioned official image tag that matches the Playwright package version in your test project. The image includes browser binaries and system dependencies, but not your project’s Playwright package, so restore and build the project in your normal workflow before running tests in the job container.

A representative CI sequence is:

  1. Start a job container from the versioned Playwright .NET image appropriate for your project and browser matrix.
  2. Check out the repository and restore dependencies.
  3. Build the test project and run dotnet test.

Image tags and supported Ubuntu variants can change. Consult the current version list in the official Docker guide rather than relying on a floating tag or assuming a particular tag remains available. A mismatch between the image’s browser version and the project’s Playwright version can prevent Playwright from finding the expected browser executable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Option 2: Install browsers in a custom .NET image

For a custom image, run the generated script after the project is built and the script exists. The following is a Dockerfile pattern for a test container based on the .NET SDK. It intentionally keeps build output and installed browsers in the same image so the example does not depend on transferring browser files between stages.

FROM mcr.microsoft.com/dotnet/sdk:8.0
WORKDIR /src

# Copy the files needed for restore first, so dependency restore can be cached.
COPY MyApp.sln ./
COPY src/MyApp/MyApp.csproj src/MyApp/
COPY tests/MyApp.Tests/MyApp.Tests.csproj tests/MyApp.Tests/
RUN dotnet restore tests/MyApp.Tests/MyApp.Tests.csproj

# Copy the rest of the repository and build the test project.
COPY . .
RUN dotnet build tests/MyApp.Tests/MyApp.Tests.csproj -c Release --no-restore

# Replace net8.0 with the target framework directory your build produced.
RUN pwsh tests/MyApp.Tests/bin/Release/net8.0/playwright.ps1 install --with-deps chromium

CMD ["dotnet", "test", "tests/MyApp.Tests/MyApp.Tests.csproj", "-c", "Release", "--no-build"]

Adapt the solution, project paths, SDK tag, and target framework to your repository. This example assumes the build environment has PowerShell available as pwsh; the official .NET examples invoke the generated PowerShell script. Confirm that the selected base image and your Docker build permissions support installing the dependencies requested by --with-deps. If PowerShell is absent, add it to the build image or choose an installation approach supported by the environment.

The command ends with chromium to install only Chromium. Omit that browser argument if the test suite needs the full set supported by the CLI, or specify the browser your tests actually use. Installing fewer browsers avoids downloading unnecessary binaries and avoids carrying browsers the test matrix never exercises. See the browser installation documentation for browser choices and download configuration.

Multi-stage images need deliberate browser handling

A common failure is installing browsers in an SDK build stage and then copying only the published ASP.NET app into a smaller runtime stage. The final stage may not contain the browser cache or the native libraries Playwright needs. If the final image will run Playwright, make sure it receives the installed browser files and required system dependencies, or install them in the final stage. Verify the final image itself, not just the build stage.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

For an application that merely serves HTTP requests while a separate test container runs browser tests, keep the responsibilities separate: build and run the ASP.NET application in its intended runtime image, and put Playwright plus browsers in the test image. This avoids adding browser assets to an image that does not launch browsers.

Match the platform and container runtime to the tests

  • Align versions. The project package expects specific browser binaries. Pin the official Docker image to a matching Playwright version, or install browsers from the script generated by the package used in the project.
  • Choose a compatible Linux distribution. The documented Firefox and WebKit browser builds depend on glibc; Alpine uses musl and is not supported for those builds. Prefer a documented glibc-based image when Firefox or WebKit is in your test matrix.
  • Use the container options recommended for browser processes. The Docker guide recommends --init to handle process management and --ipc=host for Chromium to reduce out-of-memory crashes. For example: docker run --init --ipc=host your-test-image. Whether --ipc=host is acceptable depends on your runtime and isolation requirements.
  • Set the trust boundary intentionally. The official image runs as root by default, which disables Chromium’s sandbox. The documentation says this may be acceptable for trusted end-to-end tests; for untrusted-site crawling or scraping, it recommends a separate user and a seccomp profile. The image is intended for testing and development and is not recommended for visiting untrusted websites.
  • Plan for restricted downloads. If the build cannot reach the browser download host, use the proxy or custom browser-download-host settings described in the browser documentation.

Run the tests in CI

The important sequence is restore and build, make compatible browsers and native dependencies available, then run the tests. The browser environment can come from the version-matched Playwright container or from the generated-script installation in a custom image. The official Playwright CI guide includes both direct browser installation and containerized-job patterns.

Keep browser installation in a Docker build layer after the project build layer that creates the script. This lets Docker reuse earlier restore/build layers when their inputs have not changed, while still rerunning browser installation if the relevant install step or its inputs change. Browser downloads add build work and image contents; the amount depends on which browsers and dependencies you install, so do not treat illustrative browser cache sizes in documentation as a guaranteed increase to your final image size.

Troubleshoot common installation failures

Playwright says the executable does not exist

The package may be present while its browser binaries are missing, or the browser cache may not be available in the final stage. Run the generated install script in the image that will execute the tests, and verify that the installed browser files persist there. Also check that the installed browser matches the package version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

The Playwright script path is missing

The script is generated by building the project with the Playwright package. Make sure dotnet build completed before the Docker RUN command that invokes playwright.ps1. Then inspect the actual output directory and replace the sample configuration or framework path accordingly.

Browser installation fails while installing system dependencies

Check that --with-deps is appropriate for the base distribution and that the build can install operating-system packages with the permissions available to it. If your chosen base image differs from the documented environment, use a compatible base or arrange the required libraries explicitly; installing browser binaries alone does not guarantee the host libraries are present.

Firefox or WebKit will not run on Alpine

The documented Firefox and WebKit browser builds depend on glibc, while Alpine is based on musl. Use a documented glibc-based Linux image for those browsers rather than treating this as a missing NuGet dependency.

Chromium crashes or exits unexpectedly in Docker

Try the documented --init and, where permitted, --ipc=host runtime options. The latter is recommended to reduce Chromium out-of-memory crashes. Also confirm that the container has the required dependencies and that the browser is not being run in a trust context where disabling the sandbox is unsafe.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Browser downloads time out or are blocked

Check outbound network access from the Docker build, then configure the proxy or custom browser download host using the environment variables and procedures in the Playwright browser guide. A successful NuGet restore does not prove that the separate browser download can reach its host.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your requirement is to capture a website screenshot or PDF—not to run browser automation tests—ScreenshotNeo provides a screenshot API and MCP server, so your app or agent can request a capture without installing Playwright browsers in its Docker image. It accepts a URL and returns an image or PDF. For Playwright testing, keep using one of the container approaches above.

One-call cURL example, with the API documentation at ScreenshotNeo API docs:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie and consent banners are accepted like a visitor, and more than 60 known consent platforms, newsletter popups, and chat widgets are removed before capture; each of these steps can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status.
  • An MCP server exposes take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients.
  • The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Can the ASP.NET app itself use Playwright?

Yes, if the application project is the project that launches browser automation, it needs the Playwright package and access to compatible browsers and system libraries at runtime. For ordinary end-to-end testing of an ASP.NET app, those dependencies usually belong in the test container instead.

Should I install every browser in the image?

Only if your tests need every browser. A narrower install such as Chromium reduces the browsers downloaded and carried by the image, while a broader test matrix requires the corresponding browser binaries to be available.

Does ScreenshotNeo replace Playwright tests?

No. It is an option for requesting website captures through an API or MCP client, not a substitute for running your project’s Playwright test suite.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.