DEFAULT_IGNORE_DEFAULT_ARGS doesn't seem to work for "--no-sandbox"

This issue has been tracked since 2022-06-23.

Describe the bug

Started a discussion about this here as well #2478 (comment)

Trying to get browserless to start Chrome with it's sandbox enabled. Setting DEFAULT_IGNORE_DEFAULT_ARGS=["--no-sandbox"] via Docker cli or docker compose doesn't actually remove the flag from the default launch args array. The only way it gets removed is if I specify ignoreDefaultArgs=--no-sandbox via URL params on the connection string.

To Reproduce
In my docker-compose.yml:

  chrome:
    image: browserless/chrome:latest
    security_opt:
      - "seccomp=../chromium.json" # Seccomp Chrome profile needed for chrome to start with it's sandbox enabled
    deploy:
      replicas: 2
    expose:
      - 3000
    environment:
     - DEFAULT_IGNORE_HTTPS_ERRORS=true
     - ENABLE_DEBUGGER=false
     - DEFAULT_IGNORE_DEFAULT_ARGS=["--no-sandbox"] # <-- This doesn't seem to do anything
     - DEFAULT_STEALTH=true
     - FUNCTION_ENABLE_INCOGNITO_MODE=true
     - KEEP_ALIVE=true
     - PREBOOT_CHROME=true
     - EXIT_ON_HEALTH_FAILURE=true

Setting the DEFAULT_IGNORE_DEFAULT_ARGS=["--no-sandbox"] as seen above and then running:

import asyncio
from playwright.async_api import async_playwright

async def screenshot(url):
    async with async_playwright() as p:
        browser = await p.chromium.connect_over_cdp('ws://chromelb:4000/')
        try:
            page = await browser.new_page()
            await page.goto(url, wait_until="networkidle")
            await page.screenshot(path=f'./screenshot.png', full_page=True)
        finally:
            await browser.close()

asyncio.run(screenshot('https://google.com'))

The above doesn't actually start Chrome without the '--no-sandbox' argument. you can double check this by running ps aux | grep --colour sandbox in the container.

However if I run the following

import asyncio
from playwright.async_api import async_playwright

async def screenshot(url):
    async with async_playwright() as p:
        browser = await p.chromium.connect_over_cdp('ws://chromelb:4000/?ignoreDefaultArgs=--no-sandbox')
        try:
            page = await browser.new_page()
            await page.goto(url, wait_until="networkidle")
            await page.screenshot(path=f'./screenshot.png', full_page=True)
        finally:
            await browser.close()

asyncio.run(screenshot('https://google.com'))

This actually starts chrome without the '--no-sandbox' argument.

Expected behavior
Unless i'm misinterpreting something, DEFAULT_IGNORE_DEFAULT_ARGS=["--no-sandbox"] in the docker-compose.yml should be enough to get Chrome to start without the --no-sandbox flag even without specifying ?ignoreDefaultArgs=--no-sandbox in the URL connection string.

More Details About Repo
Owner Name browserless
Repo Name chrome
Full Name browserless/chrome
Language TypeScript
Created Date 2017-11-17
Updated Date 2023-03-22
Star Count 5309
Watcher Count 47
Fork Count 516
Issue Count 29

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date