My Script changed to
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
.
I tried to change as much as I could