我正在使用以下Dockerfile来启动celery:
FROM python:3.7-alpine
RUN apk add --no-cache postgresql-libs && \
apk add --no-cache gcc musl-dev postgresql-dev zlib-dev jpeg-dev && \
apk add --no-cache graphviz-dev # some required by my project libs
ADD ./project/requirements.txt /
RUN pip3 install -r /requirements.txt
ADD ./project /app
RUN adduser -S celery
USER celery
WORKDIR /app
CMD ["/usr/local/bin/celery", "-A", "project", "worker", "--concurrency", "20", "-E", "-l", "info", "--statedb=/celery/celery.state"]
当我运行它时,它无法以错误KeyError: 'db'
开始。完整的追溯(我从-l debug
开始做芹菜):
project_celery | [2019-04-04 16:27:51,178: DEBUG/MainProcess] | Worker: Preparing bootsteps.
project_celery | [2019-04-04 16:27:51,182: DEBUG/MainProcess] | Worker: Building graph...
project_celery | [2019-04-04 16:27:51,183: DEBUG/MainProcess] | Worker: New boot order: {StateDB, Timer, Hub, Pool, Autoscaler, Beat, Consumer}
project_celery | Traceback (most recent call last):
project_celery | File "/usr/local/lib/python3.7/site-packages/kombu/utils/objects.py", line 42, in __get__
project_celery | return obj.__dict__[self.__name__]
project_celery | KeyError: 'db'
project_celery |
project_celery | During handling of the above exception, another exception occurred:
project_celery |
project_celery | Traceback (most recent call last):
project_celery | File "/usr/local/bin/celery", line 10, in <module>
project_celery | sys.exit(main())
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/__main__.py", line 16, in main
project_celery | _main()
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bin/celery.py", line 322, in main
project_celery | cmd.execute_from_commandline(argv)
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bin/celery.py", line 496, in execute_from_commandline
project_celery | super(CeleryCommand, self).execute_from_commandline(argv)))
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bin/base.py", line 275, in execute_from_commandline
project_celery | return self.handle_argv(self.prog_name, argv[1:])
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bin/celery.py", line 488, in handle_argv
project_celery | return self.execute(command, argv)
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bin/celery.py", line 420, in execute
project_celery | ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bin/worker.py", line 223, in run_from_argv
project_celery | return self(*args, **options)
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bin/base.py", line 238, in __call__
project_celery | ret = self.run(*args, **kwargs)
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bin/worker.py", line 257, in run
project_celery | **kwargs)
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/worker/worker.py", line 101, in __init__
project_celery | self.setup_instance(**self.prepare_args(**kwargs))
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/worker/worker.py", line 141, in setup_instance
project_celery | self.blueprint.apply(self, **kwargs)
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bootsteps.py", line 214, in apply
project_celery | step.include(parent)
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bootsteps.py", line 343, in include
project_celery | return self._should_include(parent)[0]
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/bootsteps.py", line 339, in _should_include
project_celery | return True, self.create(parent)
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/worker/components.py", line 215, in create
project_celery | w._persistence = w.state.Persistent(w.state, w.statedb, w.app.clock)
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/worker/state.py", line 189, in __init__
project_celery | self.merge()
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/worker/state.py", line 197, in merge
project_celery | self._merge_with(self.db)
project_celery | File "/usr/local/lib/python3.7/site-packages/kombu/utils/objects.py", line 44, in __get__
project_celery | value = obj.__dict__[self.__name__] = self.__get(obj)
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/worker/state.py", line 266, in db
project_celery | return self.open()
project_celery | File "/usr/local/lib/python3.7/site-packages/celery/worker/state.py", line 193, in open
project_celery | self.filename, protocol=self.protocol, writeback=True,
project_celery | File "/usr/local/lib/python3.7/shelve.py", line 243, in open
project_celery | return DbfilenameShelf(filename, flag, protocol, writeback)
project_celery | File "/usr/local/lib/python3.7/shelve.py", line 227, in __init__
project_celery | Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
project_celery | File "/usr/local/lib/python3.7/dbm/__init__.py", line 94, in open
project_celery | return mod.open(file, flag, mode)
project_celery | _gdbm.error: [Errno 13] Permission denied
我尝试仅从python:3.7
基本映像开始,但是发生相同的错误。
怎么了?
答案 0 :(得分:1)
尝试向您的Dockerfaile添加类似的内容:
RUN mkdir /celery && chown celery /celery