简体   繁体   English

集装箱芹菜工人不会在docker上开始撰写

[英]Containerised celery worker won't start on docker-compose up

My knowledge to docker is pretty limited so I came here posting this celery worker service won't start with the following error: 我对docker的了解非常有限,所以我来到这里发布此celery worker服务不会从以下错误开始:

ERROR: for api_worker_1 Cannot start service worker: b'OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \\"worker\\": executable file not found in $PATH": unknown' 错误:对于api_worker_1无法启动服务工作者:b'OCI运行时创建失败:container_linux.go:348:启动容器进程引起了“ exec:\\” worker \\”:在$ PATH中找不到可执行文件”:未知'

DockerFile Docker文件

# web
FROM python:2.7
RUN apt-get update
RUN apt-get install -y swig
RUN apt-get install -y libssl1.0-dev
RUN pip install --upgrade pip
ADD . /app
WORKDIR /app
CMD ["python", "-u","app.py"]

docker-compose.yml docker-compose.yml

version: '2' 
services:

  db:
    image: postgres
    restart: always
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  web:
    restart: always
    build: .
    volumes:
      - ./web:/data/web
      - .:/app
    command: python -u app.py
    ports:
     - "5000:5000"

  rabbit:
    hostname: rabbit
    image: rabbitmq:latest
    environment:
      - RABBITMQ_DEFAULT_USER=guest
      - RABBITMQ_DEFAULT_PASS=guest
    ports:
      - "5672:5672"

  worker:
    restart: always
    build: .
    volumes:
      - .:/app
    command: celery worker -B -l info -A app.tasks.celery
    links:
      - db
      - rabbit
      - web
    depends_on:
      - web

Looking at the worker service: 看工人服务:

  worker:
    restart: always
    build: .
    volumes:
      - .:/app
    command: celery worker -B -l info -A app.tasks.celery

I'm not using/installing the celery from docker. 我没有从docker使用/安装celery。 As this is rather a worker image instead of celery image. 因为这是工作人员图像而不是芹菜图像。

This is running with flask application and it was recently working. 这与flask应用程序一起运行,并且最近正在运行。 After cleaning up or deleting images and containers. 清理或删除图像和容器后。 Running docker-compose build and docker-compose up yield the 运行docker-compose builddocker-compose up产生

OCI runtime create failed:.. OCI运行时创建失败:

Error afterward. 之后发生错误。

UPDATE 更新

I updated the title of the question because celery title is misleading here. 我更新了问题的标题,因为此处的芹菜标题令人误解。 This is rather a worker service which doesn't have a DockerFile on it. 这是一个工作程序服务,上面没有DockerFile It is a service to start a celery worker which resides on app/tasks/celery . 这是启动驻留在app/tasks/celery上的celery worker的服务。

In your docker-compose file, you have specified the same build context ( build: . ) for both web and worker . 在docker-compose文件中,您为webworker指定了相同的构建上下文( build: . worker The Dockerfile you posted above is being used to build the web image AND the worker image, and clearly celery is not installed in that image. 您上面发布的Dockerfile被用于构建web映像和worker映像,并且显然该映像中未安装celery

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM