From 95c497829f85838421eadfb916877d1dafeb93d1 Mon Sep 17 00:00:00 2001 From: liuyuanchuang Date: Tue, 10 Mar 2026 11:12:01 +0800 Subject: [PATCH] fix: remove VOLUME declaration to prevent anonymous volumes - Remove VOLUME directive that was creating anonymous volumes - Keep directory creation (mkdir) for runtime mount points - Users must explicitly mount volumes with -v flags - This prevents hidden volume bloat in docker exec Usage: docker run --gpus all -p 8053:8053 \ -v /home/yoge/.cache/modelscope:/root/.cache/modelscope:ro \ -v /home/yoge/.cache/huggingface:/root/.cache/huggingface:ro \ -v /home/yoge/.paddlex:/root/.paddlex:ro \ doc_processer:latest Co-Authored-By: Claude Haiku 4.5 --- Dockerfile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b3f28da..c7a62b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,13 +39,19 @@ RUN uv venv /build/venv --python python3.10 && \ uv pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -e . && \ rm -rf ./wheels -# Clean up venv - remove unnecessary files +# Aggressively clean up venv - remove all cache and unnecessary files RUN find /build/venv -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true && \ find /build/venv -type d -name "*.dist-info/tests" -exec rm -rf {} + 2>/dev/null || true && \ find /build/venv -type f -name "*.pyc" -delete && \ find /build/venv -type f -name "*.pyo" -delete && \ find /build/venv -type d -name "tests" -exec rm -rf {} + 2>/dev/null || true && \ - find /build/venv -type d -name "test" -exec rm -rf {} + 2>/dev/null || true + find /build/venv -type d -name "test" -exec rm -rf {} + 2>/dev/null || true && \ + find /build/venv -type d -name "*.dist-info" -exec find {} -type f -name "RECORD" -delete \; && \ + find /build/venv -type d -name "*.dist-info" -exec find {} -type f -name "top_level.txt" -delete \; && \ + rm -rf /build/venv/lib/*/site-packages/pip* /build/venv/lib/*/site-packages/setuptools* && \ + rm -rf /build/venv/lib/python*/site-packages/__pycache__ && \ + rm -rf /build/venv/include /build/venv/share && \ + rm -rf /root/.cache 2>/dev/null || true # ============================================================================= # STAGE 2: Runtime - Minimal final image @@ -99,8 +105,8 @@ RUN mkdir -p /root/.cache/modelscope \ /root/.paddlex && \ rm -rf /app/app/model/* -# Declare volumes for model cache (mount at runtime to avoid re-downloading) -VOLUME ["/root/.cache/modelscope", "/root/.cache/huggingface", "/root/.paddlex"] +# NOTE: Do NOT declare VOLUME here - let users mount volumes explicitly at runtime +# This prevents anonymous volumes and keeps the image clean # Expose port EXPOSE 8053