OSError: [Errno 8] when running selenium in python in a docker container -


i've learned basics of docker , how create , run images. i'm trying create image of python script scrapes webpages data , uploads server. i'm using selenium, chromium, , windows chromedriver. i'm trying build image on windows machine , able deploy on bunch of linux/windows servers. currently, i'm building , running on same windows machine, until running, keep getting same error, though script runs fine directly on machine itself.

this error:

traceback (most recent call last):   file "my-app.py", line 796, in <module>     startscraper();   file "my-app.py", line 92, in startscraper     browser = webdriver.chrome(chrome_options = options, executable_path = path_to_chromedriver);   file "/usr/local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__     self.service.start()   file "/usr/local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 74, in start     stdout=self.log_file, stderr=self.log_file)   file "/usr/local/lib/python3.6/subprocess.py", line 707, in __init__     restore_signals, start_new_session)   file "/usr/local/lib/python3.6/subprocess.py", line 1326, in _execute_child     raise child_exception_type(errno_num, err_msg) oserror: [errno 8] exec format error 

it seems related chrome options when remove "add-argument" options, error persists, here options:

options = webdriver.chromeoptions(); options.binary_location = './chrome-win32/chrome.exe'; options.add_argument('headless') options.add_argument('window-size=1400x1300') options.add_argument('--mute-audio') options.add_argument('--disable-web-security'); options.add_argument('--allow-running-insecure-content'); options.add_argument('--ignore-certificate-errors') options.add_argument('--ignore-ssl-errors') prefs = {"profile.managed_default_content_settings.images":2} options.add_experimental_option("prefs", prefs); path_to_chromedriver = './chromedriver.exe'; 

is there i'm missing able run scraper in container? thanks!

edit: forgot add dockerfile , how build/run image:

dockerfile:

from python:3.6.0  workdir /my-app  add . /my-app  run pip install -r requirements.txt  env name scraper  cmd ["python", "my_app.py"] 

build/run image: - docker build -t myapp - docker run myapp

maybe there options don't know i'm missing?

you trying run exe inside linux container , not going work. need install chrome , chromedriver inside dockerfile , update code use correct path

from python:3.6.0 run apt update && apt install -y chromedriver workdir /my-app add . /my-app run pip install -r requirements.txt  env name scraper  cmd ["python", "my_app.py"] 

change code to

options = webdriver.chromeoptions(); options.add_argument('headless') options.add_argument('window-size=1400x1300') options.add_argument('--mute-audio') options.add_argument('--disable-web-security'); options.add_argument('--allow-running-insecure-content'); options.add_argument('--ignore-certificate-errors') options.add_argument('--ignore-ssl-errors') prefs = {"profile.managed_default_content_settings.images":2} options.add_experimental_option("prefs", prefs); path_to_chromedriver = '/usr/lib/chromium/chromedriver'; 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -