'Unable to run geckodriver on Docker image with Mac M1 chip. selenium WebDriverException: Message: Process unexpectedly closed with status 1
I've successfully built a Docker image but can't seem to be able to run it. This is my Dockerfile:
FROM python:3.9
RUN apt-get update
#install system depend
RUN apt-get install -y software-properties-common
#Download and install Fire
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A6DCF7707EBC211F
RUN apt-add-repository "deb http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu bionic main" -y
RUN apt-get update -y
RUN apt-get install firefox -y
# Download and install geckodriver
RUN GECKODRIVER_VERSION=$(curl https://github.com/mozilla/geckodriver/releases | grep -Eo 'v0+.[0-9]+.[0-9]+' | head -1) && \
wget https://github.com/mozilla/geckodriver/releases/download/"$GECKODRIVER_VERSION"/geckodriver-"$GECKODRIVER_VERSION"-macos-aarch64.tar.gz && \
tar -xvzf geckodriver* && \
chmod +x geckodriver && \
mv geckodriver /usr/local/bin
ENV DISPLAY=:99
#Install depend and cop files
COPY . .
RUN pip install -r requirements.txt
CMD ["python3", "scrapper_class.py"]
I've also got a scrapper_class.py file, in which I do:
from selenium.webdriver.firefox.service import Service
from webdriver_manager.firefox import GeckoDriverManager
...
self.driver = webdriver.Firefox(service = Service(GeckoDriverManager().install()))
and it's throwing this error:
Traceback (most recent call last):
File "//scrapper_class.py", line 914, in <module>
bot = Scrapper()
File "//scrapper_class.py", line 31, in __init__
self.driver = webdriver.Firefox(service = Service(GeckoDriverManager().install()))
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/firefox/webdriver.py", line 181, in __init__
RemoteWebDriver.__init__(
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 269, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 360, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 425, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1
can anyone tell me what I'm doing wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
