【问题标题】:Cannot run PlayWright inside docker image无法在 docker 映像中运行 PlayWright
【发布时间】:2021-11-27 01:21:15
【问题描述】:

我正在尝试与剧作家一起创建 .net 5.0 docker 映像。 这是我的 DockerFile:

FROM mcr.microsoft.com/dotnet/runtime:5.0-buster-slim AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["Agent.csproj", "Agent/"]
RUN dotnet restore "Agent/Agent.csproj"
COPY . "/src/Agent"
WORKDIR "/src/Agent"
RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq curl git nano
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -yq nodejs build-essential
RUN npm install -g npm

RUN dotnet add package Microsoft.Playwright
RUN dotnet build "Agent.csproj" -c Release -o /app/build
RUN npx playwright install

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

Executable doesn't exist at /root/.cache/ms-playwright/chromium-907428/chrome-linux/chrome
Please run the following command to download new browsers:              
║                                                                         
║     npx playwright install

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

【问题讨论】:

    标签: .net docker dockerfile playwright playwright-sharp


    【解决方案1】:

    我的问题是我安装了不同版本的 chromium v​​s playwright

    【讨论】:

      【解决方案2】:

      我认为这是Playwright 中的一个已知问题。可以看详细讨论here,特别看这个comment

      我见过的最有效的解决方案是完全删除node_modules,然后重新安装它,或者如果是docker镜像,请尝试link中提到的解决方案,通过设置playwright浏览器到特定路径

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2022-08-23
        • 1970-01-01
        • 2021-11-18
        • 2021-06-24
        • 2017-01-06
        • 2016-07-15
        • 2021-01-21
        相关资源
        最近更新 更多