-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[Question]: Missing X server or $DISPLAY error while running xvfb-run in docker #14250
Comments
I'm also getting the same error. Running the test from docker container with jenkins pipeline. |
I tried to reproduce but it works for me:
could you share with us a repro without Jenkins etc? |
Could you share your Dockerfile?
|
I did the following: And used an snippet from the docs which launches a browser instance. |
I've used the same docker image, but I've reinstalled python to 3.9 Dockerfile:
requirements.txt:
|
How does browser.py look like? something which I can easily run locally would be nice! |
Here is a short version without additional parameters
By the way: |
This is using playwright_stealth which is not supported. I did the following which makes it work for me:
Then it was working for me. |
@mxschmitt Doesn't worked for me. No output, just script freeze on run. |
I was using the official Docker image: |
Works for me as well, the command I ran inside docker is : xvfb-run --auto-servernum --server-num=1 --server-args='-screen 0, 1920x1080x24' python test.py # test.py
from playwright.async_api import Playwright, async_playwright, expect
import asyncio
async def run(playwright: Playwright) -> None:
browser_args = [
'--window-size=1300,570',
'--window-position=000,000',
'--disable-dev-shm-usage',
'--no-sandbox',
'--disable-web-security',
'--disable-features=site-per-process',
'--disable-setuid-sandbox',
'--disable-accelerated-2d-canvas',
'--no-first-run',
'--no-zygote',
'--use-gl=egl',
'--disable-blink-features=AutomationControlled',
'--disable-background-networking',
'--enable-features=NetworkService,NetworkServiceInProcess',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-breakpad',
'--disable-client-side-phishing-detection',
'--disable-component-extensions-with-background-pages',
'--disable-default-apps',
'--disable-extensions',
'--disable-features=Translate',
'--disable-hang-monitor',
'--disable-ipc-flooding-protection',
'--disable-popup-blocking',
'--disable-prompt-on-repost',
'--disable-renderer-backgrounding',
'--disable-sync',
'--force-color-profile=srgb',
'--metrics-recording-only',
'--enable-automation',
'--password-store=basic',
'--use-mock-keychain',
'--hide-scrollbars',
'--mute-audio'
]
chromium = playwright.chromium
browser = await chromium.launch(
headless=False,
args=browser_args,
)
context = await browser.new_context(
ignore_https_errors=True,
locale='en-US',
permissions=['notifications'],
)
page = await context.new_page()
await page.goto('https://google.com', wait_until='networkidle')
print(page.url)
await context.close()
await browser.close()
async def main():
async with async_playwright() as playwright:
await run(playwright)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close() This is the output: root@4f7680af8851:~# xvfb-run --auto-servernum --server-num=1 --server-args='-screen 0, 1920x1080x24' python test.py
https://www.google.com/
root@4f7680af8851:~# |
Closing this since there's no repro. If this still happens for you and you think the issue is on Playwright side, please re-file with a repro that we can debug! |
I'm running into this issue while trying to run a fastapi server with poetry. The error message is Here is my Dockerfile:
And here is the fastapi endpoint that throws the above error:
|
Your question
I'm trying to run playwright script in docker with headless=False option and with hvfb-run but got an error
I use a
mcr.microsoft.com/playwright/python:v1.22.0-focal
image,ENV DISPLAY :99
and my CMD look's like:
xvfb-run --auto-servernum --server-num=1 --server-args='-screen 0, 1920x1080x24' python3 browser.py param
Any ideas what am I doing wrong?
The text was updated successfully, but these errors were encountered: