Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run headed browser in docker #367

Open
tanwar4 opened this issue Dec 23, 2024 · 3 comments
Open

Unable to run headed browser in docker #367

tanwar4 opened this issue Dec 23, 2024 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@tanwar4
Copy link

tanwar4 commented Dec 23, 2024

When I set headless=False while running crawl4ai in docker container, I get this error

Browser logs:

╔════════════════════════════════════════════════════════════════════════════════════════════════╗
║ Looks like you launched a headed browser without having a XServer running.                     ║
║ Set either 'headless: true' or use 'xvfb-run <your-playwright-app>' before running Playwright. ║
║                                                                                                ║
║ <3 Playwright Team                                                                             ║
╚════════════════════════════════════════════════════════════════════════════════════════════════╝
Call log:
<launching> /root/.cache/ms-playwright/chromium-1134/chrome-linux/chrome --disable-field-trial-config --disable-background-networking --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,PlzDedicatedWorker --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 --unsafely-disable-devtools-self-xss-warnings --no-sandbox --no-sandbox --disable-dev-shm-usage --no-first-run --no-default-browser-check --disable-infobars --window-position=0,0 --ignore-certificate-errors --ignore-certificate-errors-spki-list --user-data-dir=/tmp/playwright_chromiumdev_profile-I2Cpd0 --remote-debugging-pipe --no-startup-window
  - <launched> pid=40
  - [pid=40][err] [40:55:1223/175702.411005:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
  - [pid=40][err] [40:40:1223/175702.417487:ERROR:ozone_platform_x11.cc(244)] Missing X server or $DISPLAY
  - [pid=40][err] [40:40:1223/175702.417529:ERROR:env.cc(258)] The platform failed to initialize.  Exiting.
@unclecode
Copy link
Owner

Oh, that's a very tricky task. Could you share the details and specifications of the Docker and the machine you are using? You need to apply several techniques, including using a virtual graphic interface, and there are a few approaches to achieve that. I'm working on incorporating it into my new Docker as a default.

@unclecode unclecode self-assigned this Dec 25, 2024
@unclecode unclecode added the question Further information is requested label Dec 25, 2024
@tanwar4
Copy link
Author

tanwar4 commented Dec 25, 2024

@unclecode I started with the basic docker image.

FROM unclecode/crawl4ai:basic-amd64

RUN apt-get update && apt-get install -y xvfb

Here's docker spec-

docker info  
Client:
 Version:    24.0.2
 Context:    desktop-linux
 Debug Mode: false
Server:
 Containers: 16
  Running: 2
  Paused: 0
  Stopped: 14
 Images: 12
 Server Version: 24.0.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dce8eb055cbb6872793272b4f20sdfsdf344f8
 runc version: v1.1.7-0-g860f061
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.49-linuxkit-pr
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 7.772GiB
 Name: docker-desktop
 ID: 0a0e13e8-5938-4db1-8f04-ba7asds668
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

The machine I am using is Mac with intel chip

@unclecode
Copy link
Owner

@tanwar4 Thx for sharing working on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants