无法在 docker 镜像内运行 PlayWright

Krz*_*tof 5 .net docker dockerfile playwright playwright-sharp

我正在尝试使用 playwright 创建 .net 5.0 docker 映像。\n这是我的 DockerFile:

\n
FROM mcr.microsoft.com/dotnet/runtime:5.0-buster-slim AS base\nWORKDIR /app\n\nFROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build\nWORKDIR /src\nCOPY ["Agent.csproj", "Agent/"]\nRUN dotnet restore "Agent/Agent.csproj"\nCOPY . "/src/Agent"\nWORKDIR "/src/Agent"\nRUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq curl git nano\nRUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -yq nodejs build-essential\nRUN npm install -g npm\n\nRUN dotnet add package Microsoft.Playwright\nRUN dotnet build "Agent.csproj" -c Release -o /app/build\nRUN npx playwright install\n
Run Code Online (Sandbox Code Playgroud)\n

但是一旦我在图像命令中运行dotnet run Agent就会出现以下错误:

\n
Executable doesn't exist at /root/.cache/ms-playwright/chromium-907428/chrome-linux/chrome\nPlease run the following command to download new browsers:              \n\xe2\x95\x91                                                                         \n\xe2\x95\x91     npx playwright install\n
Run Code Online (Sandbox Code Playgroud)\n

即使我的 dockerfile 包含RUN npx playwright install似乎没有安装它。当我将其从 dockerfile 中删除并在运行映像上手动执行它时,似乎没问题。我有什么想法可以使用 dockerfile 正确执行 playwright 安装吗?

\n

Krz*_*tof 0

我的问题是我安装了不同版本的 chromium 与 playwright