基于 docker 把 Label Studio 的 Django DB 从 SQLite 迁移到 PostgreSQL
# 1. 创建一个新的 Docker 网络,以便容器之间可以彼此通信
docker network create label-studio-net
# 2. 启动一个 PostgreSQL 容器,并设置必要的环境变量
docker run --rm -d --name label-studio-db \
--network label-studio-net \
-e POSTGRES_DB=label-studio \
-e POSTGRES_USER=label-studio \
-e POSTGRES_PASSWORD=label-studio \
-v pgdata:/var/lib/postgresql/data \
postgres:12-alpine
# 3. 停止并删除原来的 Label Studio 容器(如果有的话)
docker stop label-studio
docker rm label-studio
# 4. 启动一个新的 Label Studio 容器,使用之前创建的网络,并通过环境变量指定 PostgreSQL 数据库
docker run --rm -d --name label-studio \
--network label-studio-net \
-e LABEL_STUDIO_DB_HOST=label-studio-db \
-e LABEL_STUDIO_DB_USER=label-studio \
-e LABEL_STUDIO_DB_PASSWORD=label-studio \
-p 8080:8080 \
-v static_volume:/label-studio/static \
-v media_volume:/label-studio/media \
-v cached_volume:/label-studio/cached \
-v projects_volume:/label-studio/projects \
-v local_settings_volume:/label-studio/label_studio/conf/project/local_settings.py \
--add-host label-studio-host:127.0.0.1 \
--add-host postgres-host:127.0.0.1 \
--add-host redis-host:127.0.0.1 \
--add-host nfs-host:127.0.0.1 \
--add-host minio-host:127.0.0.1 \
--add-host ml-host:127.0.0.1 \
--add-host rabbitmq-host:127.0.0.1 \
--add-host websocket-host:127.0.0.1 \
--add-host db-host:label-studio-db \
--add-host redis-cache-host:label-studio-db \
--add-host redis-queue-host:label-studio-db \
--add-host minio-host:label-studio-db \
--add-host nfs-host:label-studio-db \
--add-host ml-host:label-studio-db \
--add-host rabbitmq-host:label-studio-db \
--add-host websocket-host:label-studio-db \
-e LABEL_STUDIO_CONTAINER_STARTED=1 \
-e LABEL_STUDIO_DB=postgres \
-e LABEL_STUDIO_REDIS_HOST=redis-host \
-e LABEL_STUDIO_NFS_HOST=nfs-host \
-e LABEL_STUDIO_MINIO_HOST=minio-host \
-e LABEL_STUDIO_ML_HOST=ml-host \
-e LABEL_STUDIO_RABBITMQ_HOST=rabbitmq-host \
-e LABEL_STUDIO_WEBSOCKET_HOST=websocket-host \
-e LABEL_STUDIO_DB_HOST=db-host \
-e LABEL_STUDIO_REDIS_CACHE_HOST=redis-cache-host \
-e LABEL_STUDIO_REDIS_QUEUE_HOST=redis-queue-host \
-e LABEL_STUDIO_MINIO_HOST=minio
评论已关闭