[Bug]: playwright fail to start while using docker
bloodcolding opened this issue · comments
Jason Wu commented
Version
1.44.0
Steps to reproduce
Just a simple java code
Playwright playwright = Playwright.create();
BrowserType chromium = playwright.chromium();
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
options.setHeadless(true)
.setSlowMo(5000)
.setChromiumSandbox(false);
Browser browser = chromium.launch(options);
Expected behavior
Boot successful.
Actual behavior
Caused by: com.microsoft.playwright.impl.TargetClosedError: Error {
message='Target page, context or browser has been closed
Browser logs:
Chromium sandboxing failed!
================================
To workaround sandboxing issues, do either of the following:
- (preferred): Configure environment to support sandboxing: https://playwright.dev/docs/troubleshooting
- (alternative): Launch Chromium without sandbox using 'chromiumSandbox: false' option
================================
name='TargetClosedError
stack='TargetClosedError: Target page, context or browser has been closed
Browser logs:
Chromium sandboxing failed!
================================
To workaround sandboxing issues, do either of the following:
- (preferred): Configure environment to support sandboxing: https://playwright.dev/docs/troubleshooting
- (alternative): Launch Chromium without sandbox using 'chromiumSandbox: false' option
================================
at DispatcherConnection.dispatch (/tmp/playwright-java-16072242212041617245/package/lib/server/dispatchers/dispatcher.js:379:15)
}
Call log:
- <launching> /ms-playwright/chromium-1105/chrome-linux/chrome --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --proxy-server=http://127.0.0.1:10809 --proxy-bypass-list=<-loopback> --user-data-dir=/tmp/playwright_chromiumdev_profile-bVtNIz --remote-debugging-pipe --no-startup-window
- <launched> pid=900
- [pid=900][err] [0604/094626.949594:ERROR:zygote_host_impl_linux.cc(100)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:256) ~[playwright-1.42.0.jar!/:1.42.0]
at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:211) ~[playwright-1.42.0.jar!/:1.42.0]
at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:118) ~[playwright-1.42.0.jar!/:1.42.0]
... 56 common frames omitted
Additional context
No response
Environment
docker: Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1
ubuntu: 22.04
playwright image: itisfoundation/osparc-playwright-e2e:2024-05
maven image: maven:3.8.5-openjdk-17-slim
Yury Semikhatsky commented
As the error message says "Running as root without --no-sandbox is not supported. See https://crbug.com/638180.". If you want to run without sandbox, you'll need launch docker with a regular user (our image has pwuser). Running with sandbox and a regular user will require configuring seccomp options.