Running Selenium with docker compose — cannot create session?

I have been trying to connect to the selenium/chrome-standalone docker container, and it is having trouble creating sessions. I keep getting the following error:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>21:02:35.263 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "18a8e2283000ca2a77b5526145bdce62","eventTime": 1719867755250989883,"eventName": "exception","attributes": {"exception.message": "Unable to create session: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: session not created: Chrome failed to start: crashed.n (disconnected: unable to connect to renderer)n (The process started from chrome location u002fusru002fbinu002fgoogle-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) nHost info: host: 'chrome', ip: '172.19.0.2'nBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknownnBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: session not created: Chrome failed to start: crashed.n (disconnected: unable to connect to renderer)n (The process started from chrome location u002fusru002fbinu002fgoogle-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) nHost info: host: 'chrome', ip: '172.19.0.2'nBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknownnBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknownntat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:221)ntat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:71)ntat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:147)ntat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:469)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:652)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:571)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:834)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:791)ntat java.baseu002fjava.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)ntat java.baseu002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)ntat java.baseu002fjava.lang.Thread.run(Unknown Source)n","exception.type": "org.openqa.selenium.SessionNotCreatedException","logger": "org.openqa.selenium.grid.distributor.local.LocalDistributor","request.payload": "[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --no-sandbox, --disable-dev-shm-usage], extensions: []}, goog:loggingPrefs: {performance: ALL}, pageLoadStrategy: normal}]"}}
</code>
<code>21:02:35.263 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "18a8e2283000ca2a77b5526145bdce62","eventTime": 1719867755250989883,"eventName": "exception","attributes": {"exception.message": "Unable to create session: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: session not created: Chrome failed to start: crashed.n (disconnected: unable to connect to renderer)n (The process started from chrome location u002fusru002fbinu002fgoogle-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) nHost info: host: 'chrome', ip: '172.19.0.2'nBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknownnBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: session not created: Chrome failed to start: crashed.n (disconnected: unable to connect to renderer)n (The process started from chrome location u002fusru002fbinu002fgoogle-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) nHost info: host: 'chrome', ip: '172.19.0.2'nBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknownnBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknownntat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:221)ntat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:71)ntat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:147)ntat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:469)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:652)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:571)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:834)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:791)ntat java.baseu002fjava.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)ntat java.baseu002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)ntat java.baseu002fjava.lang.Thread.run(Unknown Source)n","exception.type": "org.openqa.selenium.SessionNotCreatedException","logger": "org.openqa.selenium.grid.distributor.local.LocalDistributor","request.payload": "[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --no-sandbox, --disable-dev-shm-usage], extensions: []}, goog:loggingPrefs: {performance: ALL}, pageLoadStrategy: normal}]"}} </code>
21:02:35.263 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "18a8e2283000ca2a77b5526145bdce62","eventTime": 1719867755250989883,"eventName": "exception","attributes": {"exception.message": "Unable to create session: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: session not created: Chrome failed to start: crashed.n  (disconnected: unable to connect to renderer)n  (The process started from chrome location u002fusru002fbinu002fgoogle-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) nHost info: host: 'chrome', ip: '172.19.0.2'nBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknownnBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: session not created: Chrome failed to start: crashed.n  (disconnected: unable to connect to renderer)n  (The process started from chrome location u002fusru002fbinu002fgoogle-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) nHost info: host: 'chrome', ip: '172.19.0.2'nBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknownnBuild info: version: '4.22.0', revision: 'c5f3146703'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.31-linuxkit', java.version: '17.0.11'nDriver info: driver.version: unknownntat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:221)ntat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:71)ntat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:147)ntat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:469)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:652)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:571)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:834)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:791)ntat java.baseu002fjava.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)ntat java.baseu002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)ntat java.baseu002fjava.lang.Thread.run(Unknown Source)n","exception.type": "org.openqa.selenium.SessionNotCreatedException","logger": "org.openqa.selenium.grid.distributor.local.LocalDistributor","request.payload": "[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --no-sandbox, --disable-dev-shm-usage], extensions: []}, goog:loggingPrefs: {performance: ALL}, pageLoadStrategy: normal}]"}}

Here is the docker-compose.yml file:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>services:
chrome:
platform: linux/x86_64
hostname: chrome
image: selenium/standalone-chrome:4.22.0-20240621
shm_size: 2gb
privileged: true
datafetcher:
build: .
depends_on:
- chrome
</code>
<code>services: chrome: platform: linux/x86_64 hostname: chrome image: selenium/standalone-chrome:4.22.0-20240621 shm_size: 2gb privileged: true datafetcher: build: . depends_on: - chrome </code>
services:
  chrome:
    platform: linux/x86_64
    hostname: chrome
    image: selenium/standalone-chrome:4.22.0-20240621
    shm_size: 2gb
    privileged: true
  datafetcher:
    build: .
    depends_on:
      - chrome

The code that is generating this error is the following:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>options = Options()
options.set_capability("goog:loggingPrefs", {"performance": "ALL"})
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
driver = webdriver.Remote("http://chrome:4444/wd/hub", options=options)
</code>
<code>options = Options() options.set_capability("goog:loggingPrefs", {"performance": "ALL"}) options.add_argument("--headless") options.add_argument("--no-sandbox") options.add_argument("--disable-dev-shm-usage") driver = webdriver.Remote("http://chrome:4444/wd/hub", options=options) </code>
options = Options()
options.set_capability("goog:loggingPrefs", {"performance": "ALL"})
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")

driver = webdriver.Remote("http://chrome:4444/wd/hub", options=options)

I tried using different versions of selenium/chrome-standalone and using the node/hub containers instead of the standalone. Any suggestions?

New contributor

Sam Ehlers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật