我们在无头 Chromium 中运行一些测试。与其他所有东西一样,我们在 Docker 中运行所有内容。现在,几天来,我的机器(Ubuntu 19.04)上的 Chromium 突然崩溃了:
这里有一个最小的 Dockerfile 用于演示:
FROM debian
RUN apt-get update && apt-get install -y --no-install-recommends chromium
CMD chromium --headless --verbose --no-sandbox --screenshot https://www.chromestatus.com
跑步sudo docker build . -t headless-chrome-crash; sudo docker run headless-chrome-crash
由于这在我同事的 Mac 和 Circle CI 上也通过了,唯一的选择就是 Docker、操作系统和机器的性能。借助 AWS,我能够将范围缩小到 Ubuntu 19.04,因为它在 18.04 经过!当我在没有docker的情况下直接在我的计算机上运行它时,它也能通过,而且它在我装有Docker的计算机上也运行了很长时间。
完整错误相当长,(看这里),但这是第一部分:
[0918/134957.717636:ERROR:viz_main_impl.cc(170)] Exiting GPU process due to errors during initialization
[0918/134957.723472:WARNING:gpu_process_host.cc(1188)] The GPU process has crashed 1 time(s)
[0918/134957.824829:FATAL:sandbox_linux.cc(382)] Check failed: !HasOpenDirectories(). InitializeSandbox() called after unexpected directories have been opened. This breaks the security of the setuid sandbox.
#0 0x55d058895449 <unknown>
#1 0x55d0587e3d36 <unknown>
#2 0x55d0587fbd14 <unknown>
#3 0x55d059a053d4 <unknown>
....
在其他机器上,它会创建screenshot.png
如下所示的内容:
[0918/120635.809655:WARNING:ipc_message_attachment_set.cc(49)] MessageAttachmentSet destroyed with unconsumed attachments: 0/1
[0918/120635.809580:WARNING:ipc_message_attachment_set.cc(49)] MessageAttachmentSet destroyed with unconsumed attachments: 0/1
[0918/120635.809768:ERROR:command_buffer_proxy_impl.cc(126)] ContextResult::kTransientFailure: Failed to send GpuChannelMsg_CreateCommandBuffer.
[0918/120636.611712:INFO:headless_shell.cc(572)] Written to file screenshot.png.
[0918/120636.621106:ERROR:browser_process_sub_thread.cc(203)] Waited 5 ms for network service
Docker 版本:
Docker version 19.03.2, build 6a30dfc
答案1
将内核降级到 4.18.0-25-generic 可以解决该问题。似乎是 Docker 与内核 5.0.0 之间不兼容。