I'm running two docker containers as follows:
one is for selenium/standalone-chrome
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome
and the main container uses host networking to connect to MySQL which is running on localhost
$ docker run --rm --network="host" $(IMAGE_REPO)
but when I tried to initiate the driver in the main container
from selenium import webdriver
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=webdriver.DesiredCapabilities.CHROME)
I got error message which is either
urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine("''",))
or
urllib3.exceptions.ProtocolError: ('Connection aborted.', error(104, 'Connection reset by peer'))
did I forget anything / any parameters when trying to establish the containers? or the value passing to command_executor should not be 'http://127.0.0.1:4444/wd/hub'?
I also tried to use docker bridge networking, but then I have no idea how to connect to MySQL server on localhost
SQLALCHEMY_URI = '{driver}://{user}:{pwd}@{host}/{db}?charset=utf8' \
.format(
driver='mysql+pymysql',
host='127.0.0.1:3306',
user='root',
pwd='0000',
db='default'
)
command_executor=localhost:4444/wd/hub? - Light.Glocalhostbut it ended in the same result. More information here: The Dockerfile of the image only hasENTRYPOINT ["python", "main.py"]and If I firstly run bash with the main container, and execute the same python file, there's no problem at all. But it fails if I directly run the container. - Chu-Hsuan Lee