使用docker时,我应该为geckodriver提供什么可执行路径?

时间:2019-02-20 15:57:21

标签: python docker

我的geckodriver与我的Dockerfile.位于同一目录

我尝试将网络驱动程序的executable_path设置为"./geckodriver""geckodriver""/app/geckodriver"

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

我收到此错误消息。

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

我的Dockerfile看起来像这样

# 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 个答案:

答案 0 :(得分:0)

错误消息说,它无法识别 PATH 中的 Firefox ,而不是geckodriver。因此,您应该在映像apt install firefox中安装Firefox或使用selenium/standalone-firefox image