使用来自.Net Core Linux Docker容器的jsreport-“不支持在没有--no-sandbox的情况下以root身份运行”

时间:2019-08-21 12:02:43

标签: docker asp.net-core jsreport

当尝试从Linux Docker容器中运行的.Net Core Web应用程序使用jsreport时,我得到以下信息:

不带--no-sandbox的root用户身份运行不受支持

完全例外:

JsReportBinaryException: Error rendering report: A critical error occurred while trying to execute the render command: Failed to launch chrome![0821/114234.143471:WARNING:resource_bundle.cc(357)] locale_file_path.empty() for locale [0821/114234.143813:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md (1). caused by error (1) -> meta = {"remoteStack":"Error: Failed to launch chrome!\n[0821/114234.143471:WARNING:resource_bundle.cc(357)] locale_file_path.empty() for locale \n[0821/114234.143813:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.\n\n\nTROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md\n\n at onClose (jsreportRuntime.js:400867:14)\n at Interface.helper.addEventListener (jsreportRuntime.js:400856:50)\n at emitNone (events.js:111:20)\n at Interface.emit (events.js:208:7)\n at Interface.close (readline.js:370:8)\n at Socket.onend (readline.js:149:10)\n at emitNone (events.js:111:20)\n at Socket.emit (events.js:208:7)\n at endReadableNT (_stream_readable.js:1064:12)\n at _combinedTickCallback (internal/process/next_tick.js:138:11)\n at process._tickCallback (internal/process/next_tick.js:180:9)"}, stack = Error: at responseToBuffer ([eval]:72595:29) at concat ([eval]:72648:40) at ConcatStream.<anonymous> ([eval]:17182:43) at emitNone (events.js:111:20) at ConcatStream.emit (events.js:208:7) at finishMaybe ([eval]:97353:14) at afterWrite ([eval]:97215:3) at _combinedTickCallback (internal/process/next_tick.js:144:20) at process._tickCallback (internal/process/next_tick.js:180:9)

以前,从IIS直接运行应用程序时,它可以工作。使用nuget软件包:

  • jsreport.AspNetCore(v2.0.2)
  • jreport.Binary(v2.5.0)
  • jreport.Binary.Linux(v2.5.0)
  • jsreport.Local(v2.1.1)

我的Dockerfile包括获取用于运行无头Chrome的库:

RUN apt-get update && \   
    apt-get install -y gnupg  libgconf-2-4 wget && \
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
    sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
    apt-get update && \
    apt-get install -y google-chrome-unstable --no-install-recommends

ENV chrome:launchOptions:args --no-sandbox

我的Startup.cs文件将jsreport设置为:

  services.AddJsReport(new LocalReporting()
                .UseBinary(
                RuntimeInformation.IsOSPlatform(OSPlatform.Windows) 
                ? jsreport.Binary.JsReportBinary.GetBinary() 
                : jsreport.Binary.Linux.JsReportBinary.GetBinary())
                .Configure((cfg) =>
                    {
                        cfg.HttpPort = 1000;
                        return cfg;
                    }
                )
                .AsUtility()
                .Create());

0 个答案:

没有答案