Docker撰写:工作目录必须是绝对路径

时间:2019-05-12 18:27:59

标签: docker-compose scrapyd

我有这个文件夹结构:

services/
        web/
           project/
                  api/
                     scrapy.cfg

这就是我构建需要scrapy.cfg的容器的方式:

  web:
    build:
      context: ./services/web
      dockerfile: Dockerfile-dev
    volumes:
      - './services/web:/usr/src/app'    
    ports:
      - 5001:5000
    depends_on:  
      - web-db
      - redis

  scrapyrt:
    image: vimagick/scrapyd:py3
    command: scrapyrt -i 0.0.0.0 -p 9080
    restart: always
    ports:
      - '9080:9080'
    volumes:
      - ./services/web:/usr/src/app
    depends_on:
      - web

但是它会引发以下错误:

ERROR: for scrapyrt  Cannot create container for service scrapyrt: the working directory './services/web/project/api' is invalid, it needs to be an absolute path
ERROR: Encountered errors while bringing up the project.

如何将此绝对路径设置为scrapy.cfg?我没有必要为此创建主机路径。

1 个答案:

答案 0 :(得分:0)

这设置了正确的路径并修复了错误:

  scrapytr:
    ...
    working_dir: /usr/src/app/project/api
    ...