Dockerfile在文件夹中运行scrapy crawl命令

时间:2018-08-02 10:15:55

标签: python docker scrapy dockerfile

我得到了一个抓痒的蜘蛛,可以在教程文件夹中的scrapy crawl estate终端中运行它。

如何使用Dockerfile中的run命令将CD光盘到tutorial文件夹并运行它?

没有RUN cd的我的Dockerfile:

FROM ubuntu:18.04
FROM python:3.6-onbuild
RUN  apt-get update &&apt-get upgrade -y&& apt-get install python-pip -y
RUN pip install --upgrade pip
RUN pip install scrapy
WORKDIR /usr/local/bin
COPY scrapy_estate/tutorial/tutorial ./
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 80

1 个答案:

答案 0 :(得分:1)

您应该在docker文件中设置WORKDIR,ENTRYPOINT和CMD:

WORKDIR /tutorial-crawler
ENTRYPOINT ["scrapy"]
CMD []

然后:

$ docker run -it image_name list
tutorial
$ docker run -it image_name crawl tutorial