/app/chromedriver文件不存在



我创建了.net-core APIImage,但当我试图运行它时,我面临这个错误:

crit: Microsoft.AspNetCore.Hosting.Diagnostics[6]
Application startup exception
OpenQA.Selenium.DriverServiceNotFoundException: The file /app/chromedriver does not exist. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html
at OpenQA.Selenium.DriverService..ctor(String servicePath, Int32 port, String driverServiceExecutableName, Uri driverServiceDownloadUrl)
at OpenQA.Selenium.Chromium.ChromiumDriverService..ctor(String executablePath, String executableFileName, Int32 port, Uri downloadUrl)
at OpenQA.Selenium.Chrome.ChromeDriverService..ctor(String executablePath, String executableFileName, Int32 port)
at OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(String driverPath, String driverExecutableFileName)
at OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(String driverPath)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout)
at Pand.Application.Scraper.UpdatePriceScraper.Start() in /src/Pand.Application/Scraper/UpdatePriceScraper.cs:line 35
at Pand.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in /src/Pand/Startup.cs:line 114
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.<UseStartup>b__1(IApplicationBuilder app)
at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)

我试图把chromedriver.exe/app文件夹,但我仍然有这个错误。值得一提的是,我复习了同样的问题,但我找不到答案。

这是我的Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src

WORKDIR /app
COPY ["NuGet.Config", "."]
COPY ["Pand/Pand.csproj", "Pand/"]
COPY ["Pand.Application/Pand.Application.csproj", "Pand.Application/"]
COPY ["Pand.Domain/Pand.Domain.csproj", "Pand.Domain/"]
COPY ["Pand.Infrastructure/Pand.Infrastructure.csproj", "Pand.Infrastructure/"]

COPY ["Pand/chromedriver.exe", "."]

RUN dotnet restore "Pand/Pand.csproj"
COPY . .
WORKDIR "/src/Pand"
RUN dotnet build "Pand.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Pand.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Pand.dll"]

如你所见,我添加了

复制("Pand/chromedriver.exe","干净)

,但似乎这个文件没有传输到Docker Container

这些是我创建和运行Docker的命令

docker build -t Pandgroup/backend -f Pand/Dockerfile .

docker run -p 8080:80 Pandgroup/backend

在COPY chromedriver命令前使用WORKDIR /app。否则它会转到/src

相关内容

  • 没有找到相关文章

最新更新