Docker Selenium Bot Fails to Start: Profile Directory Not Found & Network Connection Issues

My Script

options = Options()
options.add_argument("--disable-gpu")
options.add_argument("--no-sandbox")
options.add_argument("--user-data-dir=/home/seluser/.config/google-chrome")
options.add_argument("--profile-directory=Profile 4")

try:
    driver = webdriver.Remote(
        command_executor=os.getenv("SELENIUM_REMOTE_URL", "http://selenium:4444/wd/hub"),
        options=options
    )
    driver.get("https://www.google.com")
    print(driver.title)
except Exception as e:
    print("Error:", e)
finally:
    if 'driver' in locals():
        driver.quit() />

My docker-compose.yml

services:
  selenium:
    image: selenium/standalone-chrome
    container_name: selenium_chrome
    shm_size: 2g
    ports:
      - "4444:4444"
      - "5900:5900"
    volumes:
      - "C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 4:/home/seluser/.config/google-chrome/Profile 4"
    command: /opt/bin/entry_point.sh
    environment:
      - SE_NODE_OVERRIDE_MAX_SESSIONS=true
      - VNC_NO_PASSWORD=1
      - SCREEN_WIDTH=1280
      - SCREEN_HEIGHT=720

  bot:
    build: .
    container_name: selenium_bot
    depends_on:
      - selenium
    environment:
      - SELENIUM_REMOTE_URL=htp://selenium:4444/wd/hub
    volumes:
      - "C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 4:/home/seluser/.config/google-chrome/Profile 4"

networks:
selenium_network:
driver: bridge

Always getting the error Error:

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: session not created

AND

Error response from daemon: container dbfc585ca9fdb317db0211fabc2cc180294894816f4c2470bef2d9d6ed0ba172 is not running

selenium_network or selenium_bot may not be connected to selenium_chrome to be open via UltraVNC

I don’t understand the title. If it is an error message, it should be quoted in the content in the right context, but you only share other error messages which have nothing to do with profile directory not found and network connection issues.

What you probably have is an HTTP error and something responds with an HTTP 500 error code, but that means there is no network issue, just an application issue and somewhere you should see error logs explaining the HTTP 500 error code. If the only error log is what you showed, there must be a “verbose” mode that shows the real reason of the HTTP error.

Assuming you have an actual issue with the profile directory, my only guess is that Linux often don’t really “like” spaces in folder names.

I’m also not sure where the container error is coming from. The context is missing here too. Is it in the same error log as the one above it?

I also fixed your error messages as you didn’t share the end of the errors so I copied the missing parts from the previous topic.

Thank you very much

`selenium_bot` does not appear in the `hostlumea107_default` network.
 `docker-compose up -d` runs, but `selenium_bot` stops immediately.
 `docker exec -it selenium_bot curl http://selenium:4444/wd/hub/status` gives a container error.
 selenium_bot can't connect to selenium:4444 → "Failed to establish a new connection: [Errno 111] Connection refused".

Despite of everything always getting the same cycle.
If someone wants for one hour sharescreen to sort out my issue. I am good to pay. (Sorry I just pissed off of this issue)

Are you running Docker Desktop or WSL? I personally doubt that this works:

They should have known it already, as this was discussed in this topic: Docker does read my path - #3 by gheorgheslicari,

To answer your question, functional knowledge about how selenium works is required. So you will need to wait until a forum user, who actually has practical experience with it, stumbles across your topic and feels like responding.

I am confident, that the number of Selenium users that use containers to run their Selenium tests, is a magnitude higher in a Selenium forum, than in a Docker community forum, where most people don’t use it.

Last time I dealt with Selenium is almost 10 years ago.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.