0

I have my geckodriver in the same directory as my Dockerfile.

I have tried setting the executable_path for my webdriver to "./geckodriver", "geckodriver" and "/app/geckodriver"

browser = webdriver.Firefox(options=options, executable_path="./geckodriver", firefox_profile=fp, capabilities=capabilities_argument)

I get this error message.

Could not find firefox in your system PATH. Please specify the binary location or install firefox

My Dockerfile looks like this

# Use an official Python runtime as a parent image
FROM python:3.6

# Set buffered environment variable
ENV PYTHONUNBUFFERED 1

# Set the working directory to /app
RUN mkdir /app
WORKDIR /app

# Make port 80 available to the world outside this container
EXPOSE 80

# Install packacges needed for crontab and selenium
RUN apt-get update && apt-get install -y sudo libpulse0 pulseaudio software-properties-common libappindicator1 fonts-liberation xserver-xephyr
RUN apt-get install binutils libproj-dev gdal-bin cron nano -y

# Install any needed packages specified in requirements.txt
ADD requirements.txt /app/
RUN pip install -r requirements.txt
ADD . /app/

# Run script
CMD ["./scrape.sh"]
  • 1
    What is the error message you are getting? – Flux Feb 20 '19 at 16:06
  • I have already tried it still no luck :( `"./geckodriver"` works locally though –  Feb 20 '19 at 16:06
  • 1
    Side note: it is best practice to use `COPY` rather than `ADD`. https://stackoverflow.com/questions/24958140/what-is-the-difference-between-the-copy-and-add-commands-in-a-dockerfile – Flux Feb 20 '19 at 16:09

1 Answers1

0

The error message says it couldn't identify Firefox in it's PATH, not the geckodriver. So you should install Firefox in your image apt install firefox or you can use selenium/standalone-firefox image

Thilak
  • 935
  • 8
  • 12
  • 1
    @ConnorMcCann side note: in addition, you should export environment variable `MOZ_HEADLESS=1` before running the script (`scrape.sh`) to ensure that firefox runs in headless mode. – Flux Feb 20 '19 at 17:17