본문 바로가기

카테고리 없음

[ERROR] failed to solve: process "/bin/sh -c pip install --no-cache-dir -r requirements.txt" did not complete successfully: exit code: 1

 

1. 에러

도커 이미지 빌드 시 아래와 같은 에러 발생

84.14 Building wheels for collected packages: logging-config, utils 84.14 Building wheel for logging-config (setup.py): started 84.92 Building wheel for logging-config (setup.py): finished with status 'done' 84.92 Created wheel for logging-config: filename=logging_config-1.0.4-py3-none-any.whl size=5274 sha256=7ab12ac0da6b88ad142b00a3bb74874a4c1a681aeb9eb44596266a68dcc4ec85 84.92 Stored in directory: /tmp/pip-ephem-wheel-cache-xn3jb3on/wheels/03/3b/24/0b4b2b620557d9862fd3db2a1cc6db326c8097415bc835af18 84.92 Building wheel for utils (setup.py): started 85.44 Building wheel for utils (setup.py): finished with status 'done' 85.44 Created wheel for utils: filename=utils-1.0.2-py2.py3-none-any.whl size=13906 sha256=dab2da1ebfc43ab165850910c123032482c8665465387406b4e767471430e165 85.44 Stored in directory: /tmp/pip-ephem-wheel-cache-xn3jb3on/wheels/b8/39/f5/9d0ca31dba85773ececf0a7f5469f18810e1c8a8ed9da28ca7 85.44 Successfully built logging-config utils 88.67 Installing collected packages: webencodings, wcwidth, pytz, pure_eval, ptyprocess, mpmath, logging-config, fastjsonschema, zipp, wrapt, widgetsnbextension, websockets, websocket-client, webcolors, uvloop, utils, urllib3, uri-template, ujson, tzdata, typing_extensions, types-python-dateutil, traitlets, tqdm, tornado, tomli, tinycss2, threadpoolctl, tenacity, sympy, soupsieve, sniffio, six, shellingham, Send2Trash, safetensors, rpds-py, rfc3986-validator, regex, pyzmq, PyYAML, python-multipart, python-json-logger, python-dotenv, Pygments, pycparser, psutil, protobuf, prompt_toolkit, prometheus_client, platformdirs, pillow, pexpect, parso, pandocfilters, packaging, overrides, orjson, opentelemetry-util-http, nvidia-nvtx-cu12, nvidia-nvjitlink-cu12, nvidia-nccl-cu12, nvidia-curand-cu12, nvidia-cufft-cu12, nvidia-cuda-runtime-cu12, nvidia-cuda-nvrtc-cu12, nvidia-cuda-cupti-cu12, nvidia-cublas-cu12, numpy, networkx, nest-asyncio, mypy-extensions, multidict, mistune, mdurl, MarkupSafe, jupyterlab_widgets, jupyterlab_pygments, jsonpointer, json5, joblib, jiter, idna, httptools, h11, grpcio, greenlet, fsspec, frozenlist, fqdn, filelock, executing, exceptiongroup, et-xmlfile, dnspython, distro, defusedxml, decorator, debugpy, click, charset-normalizer, certifi, babel, attrs, async-timeout, appnope, annotated-types, aiohappyeyeballs, yarl, uvicorn, typing-inspect, triton, terminado, SQLAlchemy, scipy, rfc3339-validator, requests, referencing, QtPy, python-dateutil, pydantic_core, opentelemetry-proto, openpyxl, nvidia-cusparse-cu12, nvidia-cudnn-cu12, matplotlib-inline, marshmallow, markdown-it-py, jupyter_core, jsonpatch, Jinja2, jedi, importlib_metadata, httpcore, googleapis-common-protos, faiss-cpu, email_validator, Deprecated, comm, cffi, bleach, beautifulsoup4, async-lru, asttokens, asgiref, anyio, aiosignal, watchfiles, tiktoken, starlette, stack-data, scikit-learn, rich, pydantic, pandas, opentelemetry-exporter-otlp-proto-common, opentelemetry-api, nvidia-cusolver-cu12, jupyter_server_terminals, jupyter_client, jsonschema-specifications, huggingface-hub, httpx, dataclasses-json, arrow, argon2-cffi-bindings, aiohttp, typer, torch, tokenizers, sse-starlette, prometheus-fastapi-instrumentator, opentelemetry-semantic-conventions, opentelemetry-instrumentation, openai, langsmith, jsonschema, isoduration, ipython, argon2-cffi, transformers, opentelemetry-sdk, opentelemetry-instrumentation-logging, opentelemetry-instrumentation-asgi, nbformat, langchain-core, ipywidgets, ipykernel, fastapi-cli, sentence-transformers, qtconsole, opentelemetry-instrumentation-fastapi, opentelemetry-exporter-otlp-proto-http, opentelemetry-exporter-otlp-proto-grpc, opentelemetry-distro, nbclient, langchain-text-splitters, langchain-openai, jupyter-events, jupyter-console, fastapi, opentelemetry-exporter-otlp, nbconvert, langchain-huggingface, langchain, langchain-community, jupyter_server, notebook_shim, jupyterlab_server, jupyter-lsp, jupyterlab, notebook, jupyter 178.8 ERROR: Could not install packages due to an OSError: [Errno 28] No space left on device: '/usr/local/lib/python3.10/site-packages/scipy/integrate/_bvp.py' 178.8 179.0 179.0 [notice] A new release of pip is available: 23.0.1 -> 24.2 179.0 [notice] To update, run: pip install --upgrade pip ------ Dockerfile:13 -------------------- 11 | # 의존성 파일 복사 및 설치 12 | COPY requirements.txt . 13 | >>> RUN pip install --no-cache-dir -r requirements.txt 14 | 15 | # 소스 코드 복사 -------------------- ERROR: failed to solve: process "/bin/sh -c pip install --no-cache-dir -r requirements.txt" did not complete successfully: exit code: 1


2. 에러 발생 이유

설치 중 디스크 공간이 부족했기 때문입니다. [Errno 28] No space left on device라는 메시지가 이를 명확하게 보여주고 있습니다. 이는 Docker 컨테이너 내의 파일 시스템에 더 이상 데이터를 쓸 수 있는 공간이 없다는 것을 의미합니다.

 

3. 해결

디스크 공간 확보

  • Docker 컨테이너에서 필요 없는 임시 파일이나 캐시를 삭제하여 디스크 공간을 확보합니다.
  • 또는, 컨테이너가 실행되고 있는 호스트 머신에서 Docker가 사용하는 디스크 공간을 늘릴 수 있습니다.

 

1) Docker 컨테이너 내에서 디스크 공간 확보

컨테이너 안에서 디스크 공간을 확보하려면, 다음 방법들을 시도해볼 수 있습니다.

  • 불필요한 패키지 삭제: 설치 후 더 이상 필요하지 않은 패키지를 제거합니다.
apt-get remove --purge <package_name>
apt-get autoremove
apt-get clean
 
  • 임시 파일 및 캐시 파일 삭제:apt와 같은 패키지 관리자가 생성한 캐시 파일을 삭제합니다.
 
 
 
apt-get clean
apt-get autoclean
  • Python 패키지 설치 시 생성된 .cache 폴더를 삭제합니다.
rm -rf ~/.cache/pip
  • /tmp 폴더 비우기: 많은 임시 파일이 /tmp 폴더에 저장될 수 있으므로, 필요 없는 파일들을 삭제합니다.
rm -rf /tmp/*

 

2) Docker 호스트 머신에서 디스크 공간 확보

호스트 머신에서 Docker가 사용하는 디스크 공간을 관리하려면, 다음과 같은 방법을 사용할 수 있습니다.

  • 불필요한 이미지, 컨테이너, 볼륨 및 네트워크 삭제:
    • 중지된 컨테이너 삭제:
docker container prune

 

  • 사용되지 않는 이미지 삭제:
docker image prune -a
  • 사용되지 않는 볼륨 삭제:
docker volume prune
  • 사용되지 않는 네트워크 삭제:
docker network prune
  • 모든 불필요한 리소스 삭제 (위의 모든 작업을 한 번에 수행):
docker system prune -a --volumes
  • Docker 데이터 디렉토리 확인 및 관리:
    • Docker는 기본적으로 /var/lib/docker 디렉토리를 사용하여 이미지, 컨테이너, 볼륨 등을 저장합니다. 이 디렉토리의 사용량을 모니터링하고, 필요에 따라 데이터를 정리하거나 외부 저장소로 이동할 수 있습니다.
  • Docker 디스크 사용량 확인:
    • Docker가 사용하는 디스크 공간을 확인하려면 다음 명령어를 사용할 수 있습니다.
docker system df

 

 

docker system df 명령어 결과

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          5         5         3.912GB   7.377MB (0%)
Containers      5         5         84.2MB    0B (0%)
Local Volumes   1         1         149.1MB   0B (0%)
Build Cache     80        0         34.74GB   34.74GB

 

Build Cache가 34.74GB로 상당히 큰 부분을 차지하고 있습니다. 이 캐시를 정리하면 많은 디스크 공간을 확보할 수 있습니다.

빌드 캐시 정리: 이 명령어를 실행하면 사용되지 않는 모든 빌드 캐시가 삭제됩니다.

docker builder prune

 

캐시 정리 후 디스크 사용량 확인

캐시를 정리한 후 다시 docker system df 명령어를 실행하여 얼마나 많은 공간이 확보되었는지 확인할 수 있습니다.