使用docker,部署一个python的爬虫项目
python用了chrome_options = webdriver.ChromeOptions() 需要安装中chrome 和 chromedriver , chromedriver 我可以放在项目中,但是需要在dockerfile 安装chrome,查询了良久,找不到解决方法
用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%
FROM python:3.9
WORKDIR /home/code
ADD . /home/code
#RUN mkdir /home/code/depends
#RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
#RUN echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
#RUN apt-get update && apt-get install -y google-chrome-stable
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
RUN sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update
RUN apt-get -y install google-chrome-stable
# 安装 requirements.txt 中指定的任何所需软件包
RUN pip install -r requirements.txt -i https://pypi.doubanio.com/simple
# 定义环境变量
#ENV NAME World
# 在容器启动时运行 app.py
CMD ["python", "/home/code/task_scheduler.py"]
上面是我的dokerfile
=> ERROR [4/9] RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 170.8s
------
> [4/9] RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -:
#8 1.430 /bin/sh: 1: sudo: not found
------
executor failed running [/bin/sh -c wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -]: exit code: 127
执行会报错
求朋友们帮忙看看