Selenium Grid driver won’t quit

I am running selenium grid within a docker container to test some processes in a Django application.

The first time I run the test, after docker-compose up I get

docker-compose exec web coverage run manage.py test researcher_UI --tag=login
Found 2 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
..E
======================================================================
ERROR: tearDownClass (researcher_UI.tests.test_processes.login_process.WebSiteOpensTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/app/researcher_UI/tests/test_processes/login_process.py", line 28, in tearDownClass
    cls.firefox.quit()
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 469, in quit
    self.execute(Command.QUIT)
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Failed to decode response from marionette


----------------------------------------------------------------------
Ran 2 tests in 7.473s

FAILED (errors=1)
Destroying test database for alias 'default'...

Please note the test ran successfully but errored when quiting the driver.

If I run the test again it won’t even open a browser instance:

docker-compose exec web coverage run manage.py test researcher_UI --tag=login
Found 2 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
E
======================================================================
ERROR: setUpClass (researcher_UI.tests.test_processes.login_process.WebSiteOpensTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/app/researcher_UI/tests/test_processes/login_process.py", line 21, in setUpClass
    cls.firefox = webdriver.Remote(
                  ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 208, in __init__
    self.start_session(capabilities)
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 292, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: 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: Process unexpectedly closed with status 1 
Host info: host: '06a8ec0d9b6d', ip: '172.18.0.3'
Build info: version: '4.19.1', revision: 'abe0ee07dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.22-linuxkit', java.version: '17.0.10'
Driver info: driver.version: unknown
Build info: version: '4.19.1', revision: 'abe0ee07dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.22-linuxkit', java.version: '17.0.10'
Driver info: driver.version: unknown
Stacktrace:
    at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:221)
    at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:71)
    at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:147)
    at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:464)
    at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:651)
    at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:570)
    at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:830)
    at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:790)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
    at java.lang.Thread.run (None:-1)

----------------------------------------------------------------------
Ran 0 tests in 0.510s

FAILED (errors=1)
Destroying test database for alias 'default'...

This is my Django test:

@tag("selenium", "login")
class WebSiteOpensTests(LiveServerTestCase):
    LiveServerTestCase.host = "web"

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        options = Options()
        cls.firefox = webdriver.Remote(
            command_executor="http://selenium:4444", options=options
        )
        cls.firefox.implicitly_wait(10)

    @classmethod
    def tearDownClass(cls):
        cls.firefox.quit()
        super().tearDownClass()

    def test_visit_home_age(self):
        self.firefox.get(f"{self.live_server_url}")
        self.assertIn(self.firefox.title, "Site Title")

    def test_visit_login_page(self):
        self.firefox.get(f"{self.live_server_url}/accounts/login/")
        self.assertIn(self.firefox.title, "Login")

This is my docker-compose.yml:

services:
  db:
      image: postgres
      volumes:
        - postgres_data:/var/lib/postgresql/data/
      environment:
        - POSTGRES_USER=postgres
        - POSTGRES_PASSWORD=postgres
      ports:
        - "5432"
      healthcheck:
        test: "exit 0"

  web: 
    build:
      context: .
      dockerfile: Dockerfile
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - ./webcdi:/app
    ports:
      - "8000:8000"
    env_file:
      - .env
    depends_on:
      - db
      
  mail:
    platform: linux/x86_64
    image: mailhog/mailhog:latest
    ports:
      - "8025:8025"

  pgadmin:
    image: dpage/pgadmin4:latest
    depends_on:
      - db
    ports:
      - "5051"
    environment:
      PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
      PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}

  selenium:
    image: selenium/standalone-firefox:latest
    ports:
      - 4444:4444

    
volumes:
  postgres_data:

I have seen posts suggesting that I need to give selenium 2gb of RAM which I have previously tried by adding (but it made no difference).

build:
   context .
   memory '2gb'

My docker desktop is set up to allow 16GB memory.

This was working a week ago, and the only thing I’ve changed is upgraded to the latest version of docker desktop (4.29.0) from 4.24 but I find it hard to believe this is the issue.

Any help most welcome

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