Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Playwright for .NET cannot find the browser inside a Docker container

ErrorMicrosoft.Playwright.PlaywrightException: Executable doesn't exist

Short answer

The container has no browser build that matches the Playwright NuGet package your code uses. Use the mcr.microsoft.com/playwright/dotnet image with the same version number as the package, or run the package's own playwright.ps1 install step in your image. Keep the browsers path the same at install and at run time.

  • Applies to Microsoft.Playwright 1.4x for .NET, .NET SDK 9, Docker 27, Ubuntu 24.04 (noble) image
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the Playwright package version in your project and compare it with the tag of the image you run. They must be the same version.

    grep -n "Microsoft.Playwright" *.csproj
    grep -n "^FROM" Dockerfile
  2. 2Match what you see, then jump to its fix

    1. 1The failure starts after the Microsoft.Playwright package or the image tag was changed on its ownThe Docker image version differs from the NuGet package versionFix
    2. 2The base image is dotnet/sdk or dotnet/aspnet, not the Playwright imageThe browsers were never installed in the imageFix
    3. 3Install succeeds in the build, but the container fails at run timeInstall and run use a different browsers location or a different userFix

What does the error look like?

  • Microsoft.Playwright.PlaywrightException: Executable doesn't exist

Cause 1 of 3

The Docker image version differs from the NuGet package version

1Check

Each Playwright release expects specific browser builds. The image only contains the builds of its own version, and the NuGet package is not part of the image.

grep -n "PackageReference.*Playwright" *.csproj
grep -n "playwright/dotnet" Dockerfile

2Fix

Pin the image tag to the exact version of the package, on the Ubuntu release you want. Docker's image page recommends pinning to a specific version.

# Dockerfile: tag matches the package version
FROM mcr.microsoft.com/playwright/dotnet:v1.64.1-noble AS runtime

3Verify

Rebuild and run the test or the app once.

docker build -t myapp . && docker run --rm --init --ipc=host myapp

Confirmed by playwright.dev

Did this fix it?

Cause 2 of 3

The browsers were never installed in the image

1Check

The .NET images do not ship Playwright browsers. They are installed by the script that the package copies into your build output.

ls bin/Release/net9.0/playwright.ps1

2Fix

Run the install script in the Dockerfile after publish. Use install --with-deps to add the Linux libraries in the same step.

RUN pwsh bin/Release/net9.0/playwright.ps1 install --with-deps chromium

3Verify

List the browser cache folder in the built image.

docker run --rm --entrypoint ls myapp ~/.cache/ms-playwright

Confirmed by playwright.dev

Did this fix it?

Cause 3 of 3

Install and run use a different browsers location or a different user

1Check

Browsers go to ~/.cache/ms-playwright on Linux by default, so installing as root and running as another user looks in a different home folder. PLAYWRIGHT_BROWSERS_PATH, when set at install, must also be set at run time.

docker run --rm --entrypoint sh myapp -c 'id; echo $PLAYWRIGHT_BROWSERS_PATH; ls ~/.cache/ms-playwright'

2Fix

Set PLAYWRIGHT_BROWSERS_PATH to one shared folder for both the install step and the running container.

ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN pwsh bin/Release/net9.0/playwright.ps1 install --with-deps chromium

3Verify

Run the container as the user you use in production.

docker run --rm --init --ipc=host myapp

Confirmed by playwright.dev

Did this fix it?

How do I stop it coming back?

  • Pin the image tag and the NuGet package to one version number and update them together.
  • Install browsers in the image build, never at container start.
  • Run the container with --ipc=host, because Chromium can run out of memory without it.
  • Run as the same user at build and run time, or set one shared browsers path.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.