doccano 在Docker环境中上传数据集时权限被拒绝,

col17t5w  于 5个月前  发布在  Docker
关注(0)|答案(1)|浏览(103)

我无法上传数据。网页显示上传过程中出现错误。
首先,我检查了服务器用户,它是root用户。
然后我查看了日志,得到了一个错误:

File "/usr/local/lib/python3.8/site-packages/django/db/models/fields/files.py", line 302, in pre_save
    file.save(file.name, file.file, save=False)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/fields/files.py", line 89, in save
    self.name = self.storage.save(name, content, max_length=self.field.max_length)
  File "/usr/local/lib/python3.8/site-packages/django/core/files/storage.py", line 54, in save
    return self._save(name, content)
  File "/usr/local/lib/python3.8/site-packages/django/core/files/storage.py", line 255, in _save
    os.makedirs(directory, exist_ok=True)
  File "/usr/local/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/doccano/backend/filepond-temp-uploads/QBEHSkNuNgqeThEZHd6RNx'

似乎程序没有权限写入这个文件夹。
所以我决定创建一个具有更高权限的新容器。
我删除了容器并使用--privileged=true创建了一个新的容器:

docker container create --name doccano --privileged=true   -e "ADMIN_USERNAME=admin"   -e "ADMIN_EMAIL=admin@example.com"   -e "ADMIN_PASSWORD=password"   -p 8000:8000 doccano/doccano

然后我启动了新容器并进入了它:

docker container start doccano
docker exec -ti doccano /bin/bash

接下来,我使用-R提高了/docano的权限,最终变成了这样:

doccano@37de5739c23a:/doccano$ ls -l
total 112
-rwxrwxrwx  1 doccano doccano  1772 Jul 26 05:00 Dockerfile
-rwxrwxrwx  1 doccano doccano  1340 Jul 26 05:00 Pipfile
-rwxrwxrwx  1 doccano doccano 88943 Jul 26 05:00 Pipfile.lock
drwxrwxrwx 28 doccano doccano  4096 Oct 12 02:35 backend
drwxrwxrwx 32 doccano doccano  4096 Oct 12 02:35 frontend
drwxrwxrwx  2 doccano doccano  4096 Oct 12 02:35 nginx
drwxrwxrwx  4 doccano doccano  4096 Oct 12 02:35 tools

但仍然无法正常工作,出现了相同的错误。
我该怎么办...?

环境

  • 操作系统:Linux 37de5739c23a 3.16.0-30-generic Feature Request: keyboard navigation (next/previous item) #40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015 x86_64 GNU/Linux
  • Python版本:Python 3.8.6
  • doccano安装时间:2021-10-12
  • 如何安装doccano(Heroku按钮等):在Readme中通过docker一次性设置

相关问题