.net - 无法在 docker 映像中运行 PlayWright
问题描述
我正在尝试与剧作家一起创建 .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 吗?
解决方案
推荐阅读
- apache-kafka - Kafka 实时流与微服务
- c++ - Window Maximize/Minimize/Restore 的 WM Windows 消息是什么?
- c# - 如何移动对象而不卡顿?
- sockets - 如何使用 unix 套接字从容器内部与 docker 守护进程通信?
- c++ - 如何在 ArrayFire 中正确使用固定内存?
- pandas - 多索引 DataFrame 到邻接矩阵序列(Numpy 3D 数组)
- android - 如何在 webview 中显示无 Internet 连接对话框 | 安卓工作室
- swift - 转换后的 Base64String 无法上传到 IMGUR API
- javascript - 未知选项 -D Gjs
- javascript - Javascript - 我可以用一个 MySQL 查询更新两个表吗?