我有 docker 集群,其中包含多个容器(例如 minio)作为文件存储和 django 上的后端,它大致如下所示:
files:
image: minio/minio
container_name: files
env_file: .env
command: server /data --console-address ":9001"
healthcheck:
test: curl -I ${MINIO_EXTERNAL_ENDPOINT}/minio/health/live
interval: 5s
timeout: 5s
retries: 5
volumes:
- s3:/data
ports:
- 9000:9000
- 9001:9001
backend:
build: ./backend
container_name: backend
env_file: .env
volumes:
- ./scripts/backend:/app/scripts
healthcheck:
test: curl --fail ${BACKEND_HC} || exit 1
interval: 10s
timeout: 5s
retries: 5
ports:
- 8000:8000
depends_on:
files:
condition: service_healthy
一切都很好,直到今天,我的 SSD 坏了,我被迫使用旧的。它只有 119 GB 的“真实”空间,所以我在 docker 桌面上做了
Troubleshoot -> Purge Data
(诅咒你,wsl/docker)。然后克隆我的项目,希望它能像往常一样启动。然后我就被标题中的错误击中了。
这是堆栈跟踪的有用部分:
backend | [2024-11-13 15:50:41 +0700] [13] [INFO] Worker exiting (pid: 13)
backend | [2024-11-13 15:50:41 +0700] [14] [ERROR] Exception in worker process
backend | Traceback (most recent call last):
...
backend | application = get_wsgi_application()
backend | ^^^^^^^^^^^^^^^^^^^^^^
backend | File "/usr/local/lib/python3.11/site-packages/django/core/wsgi.py", line 12, in get_wsgi_applicati
on
backend | django.setup(set_prefix=False)
backend | File "/usr/local/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
backend | apps.populate(settings.INSTALLED_APPS)
backend | File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 124, in populate
backend | app_config.ready()
backend | File "/usr/local/lib/python3.11/site-packages/django_minio_backend/apps.py", line 31, in ready
backend | mbs = MinioBackendStatic()
backend | ^^^^^^^^^^^^^^^^^^^^
backend | File "/usr/local/lib/python3.11/site-packages/django_minio_backend/models.py", line 482, in __init
__
backend | self.check_bucket_existence() # make sure the `MINIO_STATIC_FILES_BUCKET` exists
backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend | File "/usr/local/lib/python3.11/site-packages/django_minio_backend/models.py", line 408, in check_
bucket_existence
backend | if not self.client.bucket_exists(self.bucket):
backend | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend | File "/usr/local/lib/python3.11/site-packages/minio/api.py", line 696, in bucket_exists
backend | self._execute("HEAD", bucket_name)
backend | File "/usr/local/lib/python3.11/site-packages/minio/api.py", line 440, in _execute
backend | return self._url_open(
backend | ^^^^^^^^^^^^^^^
backend | File "/usr/local/lib/python3.11/site-packages/minio/api.py", line 423, in _url_open
backend | raise response_error
backend | minio.error.S3Error: S3 operation failed; code: AccessDenied, message: Access denied, resource: /loc
al-static, request_id: 18077B04951EF538, host_id: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e
3e8, bucket_name: local-static
如您所见,minio 尝试验证存储桶
local-static
是否存在,但失败了。我使用的唯一凭据是根用户访问/密钥,因此我无法拒绝访问。我从未使用过任何策略,因此无需配置任何内容,因此我不知道要修复什么
好吧,我只是愤怒地删除了该项目并清除了docker中的所有数据,然后克隆并再次构建它,这个问题就消失了。