Playwright for .NET cannot find the browser inside a Docker container
Microsoft.Playwright.PlaywrightException: Executable doesn't existShort 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.
Fix it fast
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" Dockerfile2Match what you see, then jump to its fix
- 1
The 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
The base image is dotnet/sdk or dotnet/aspnet, not the Playwright imageThe browsers were never installed in the imageFix - 3
Install succeeds in the build, but the container fails at run timeInstall and run use a different browsers location or a different userFix
- 1
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" Dockerfile2Fix
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 runtime3Verify
Rebuild and run the test or the app once.
docker build -t myapp . && docker run --rm --init --ipc=host myappConfirmed by playwright.dev
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.ps12Fix
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 chromium3Verify
List the browser cache folder in the built image.
docker run --rm --entrypoint ls myapp ~/.cache/ms-playwrightConfirmed by playwright.dev
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 chromium3Verify
Run the container as the user you use in production.
docker run --rm --init --ipc=host myappConfirmed by playwright.dev
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- RaheebA consumer app shipped to both stores from one Flutter codebase on a .NET and Azure back end.
Related fixes
Servers
dotnet says it cannot find any installed .NET SDKs (in Docker or on a server)
A compatible .NET SDK was not found
The dotnet command found a runtime but no SDK that fits.
3 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
A containerized ASP.NET Core app says the framework Microsoft.AspNetCore.App was not found
Framework: 'Microsoft.AspNetCore.App', version '6.0.0' (x64)
The app asks for a shared framework the final image does not have.
3 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
dnf fails to download repo metadata in a CentOS 8 Docker build
The same Dockerfile built fine before 2022
CentOS Linux 8 reached end of life on 31 December 2021 and its content left the mirrors.
2 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fix