Cannot run python script in Docker using chromedriver

Viewed 18

After building the Docker file, trying to run the image when the python sript starts return this error:

Traceback (most recent call last):
  File "/data/ms_rewards_farmer.py", line 815, in <module>
     browser = browserSetup(True, PC_USER_AGENT)
  File "/data/ms_rewards_farmer.py", line 48, in browserSetup
      chrome_browser_obj = webdriver.Chrome(options=options)
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 
      69, in __init__
      super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 
      89, in __init__ 
      self.service.start()
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 71, 
      in start self.process = subprocess.Popen(cmd, env=self.env,
  File "/usr/local/lib/python3.9/subprocess.py", line 951, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.9/subprocess.py", line 1823, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  OSError: [Errno 8] Exec format error: 'chromedriver'

This is the Dockerfile:

FROM python:3.9.2

RUN mkdir -p /logs

RUN apt-get update
RUN apt install wget

RUN apt-get install -y wget xvfb unzip

# install google chrome
RUN apt-get install -y chromium

# install chromedriver
RUN wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip
RUN unzip chromedriver_linux64.zip
RUN mv chromedriver /usr/bin/chromedriver
RUN chown root:root /usr/bin/chromedriver
RUN chmod +x /usr/bin/chromedriver

COPY . /data
WORKDIR /data
RUN pip install --no-cache-dir -r requirements.txt

# set display port to avoid crash
ENV DISPLAY=:99

# Custom Env Vars
ENV DOCKER_IMAGE=true

I don't know what's the problem, i tried to change the installation of chromedriver from the Dockerfile, any ideas?

Requirements.txt:

certifi
chardet
idna
requests
selenium
urllib3
ipapi
schedule
0 Answers
Related