자유게시판
여러분의 의견을 자유롭게 알려주세요.
하지만, 책을 끝까지 읽고 나면 이 페이지도 만드실 수 있을거에요.
p.573 docker-compose build 에러
2 years, 8 months ago
qwefghnm1212안녕하세요 작가님
제가 docker-compose build 하는 부분에서 계속에러가 나타나서 질문드립니다
일단, 작가님께서 다른분들에거 추천하신 방법은 했습니다.
첫번째로, pip 최신으로 업데이트하기
두번째로, Dockerfile 수정하기
하지만 그래도 docker-compose build를 해도 오류가 계속뜨네요
현재상황
-Dockerfile
```
#pull official base image
FROM python:3.9-slim-buster
#set work directory
WORKDIR /usr/src/app
#set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY . /usr/src/app/
#install dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt```
-docker-compose.yml
```
version: '3'
services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./:/usr/src/app/
ports:
- 8000:8000
env_file:
- ./.env.dev
```
.env.dev
```
DEBUG=1
SECRET_KEY=*****************
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
SQL_ENGINE=django.db.backends.postgresql
SQL_DATABASE=Jusarang_Youth_dev
SQL_USER=Jusarang_Youth_db_user
SQL_PASSWORD=Jusarang_Youth_db_password
SQL_HOST=db
SQL_PORT=5432
```
에러 내용
```
(venv) PS C:\mywork\Jusarang_Youth_Web> docker-compose build
[+] Building 27.6s (9/9) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3.9-slim-buster 2.7s
=> [internal] load build context 3.3s
=> => transferring context: 1.60MB 3.2s
=> [1/5] FROM docker.io/library/python:3.9-slim-buster@sha256:50e50d77a71944baa9b6f4e903d12ff3b5b6b1120ab 0.0s
=> CACHED [2/5] WORKDIR /usr/src/app 0.0s
=> [3/5] COPY . /usr/src/app/ 4.0s
=> [4/5] RUN pip install --upgrade pip 5.8s
=> ERROR [5/5] RUN pip install -r requirements.txt 11.7s
------
> [5/5] RUN pip install -r requirements.txt:
#9 1.749 Collecting asgiref==3.5.0
#9 1.802 Downloading asgiref-3.5.0-py3-none-any.whl (22 kB)
#9 1.853 Collecting asttokens==2.0.5
#9 1.864 Downloading asttokens-2.0.5-py2.py3-none-any.whl (20 kB)
#9 1.902 Collecting backcall==0.2.0
#9 1.915 Downloading backcall-0.2.0-py2.py3-none-any.whl (11 kB)
#9 1.970 Collecting beautifulsoup4==4.10.0
#9 1.982 Downloading beautifulsoup4-4.10.0-py3-none-any.whl (97 kB)
#9 2.004 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.4/97.4 KB 5.0 MB/s eta 0:00:00
#9 2.059 Collecting black==22.1.0
#9 2.073 Downloading black-22.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB)
#9 2.256 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.5/1.5 MB 8.2 MB/s eta 0:00:00
#9 2.304 Collecting certifi==2021.10.8
#9 2.317 Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
#9 2.341 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 149.2/149.2 KB 7.1 MB/s eta 0:00:00
#9 2.606 Collecting cffi==1.15.0
#9 2.623 Downloading cffi-1.15.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (444 kB)
#9 2.681 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 444.3/444.3 KB 8.3 MB/s eta 0:00:00
#9 2.727 Collecting charset-normalizer==2.0.12
#9 2.739 Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
#9 2.798 Collecting click==8.0.4
#9 2.809 Downloading click-8.0.4-py3-none-any.whl (97 kB)
#9 2.829 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.5/97.5 KB 5.4 MB/s eta 0:00:00
#9 2.873 Collecting colorama==0.4.4
#9 2.886 Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
#9 3.220 Collecting cryptography==36.0.1
#9 3.234 Downloading cryptography-36.0.1-cp36-abi3-manylinux_2_24_x86_64.whl (3.6 MB)
#9 3.669 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.6/3.6 MB 8.4 MB/s eta 0:00:00
#9 3.722 Collecting decorator==5.1.1
#9 3.733 Downloading decorator-5.1.1-py3-none-any.whl (9.1 kB)
#9 3.777 Collecting defusedxml==0.7.1
#9 3.791 Downloading defusedxml-0.7.1-py2.py3-none-any.whl (25 kB)
#9 3.950 Collecting Django==3.0.6
#9 3.963 Downloading Django-3.0.6-py3-none-any.whl (7.5 MB)
#9 4.959 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.5/7.5 MB 7.5 MB/s eta 0:00:00
#9 5.120 Collecting django-allauth==0.49.0
#9 5.133 Downloading django-allauth-0.49.0.tar.gz (702 kB)
#9 5.233 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 702.3/702.3 KB 7.2 MB/s eta 0:00:00
#9 5.672 Preparing metadata (setup.py): started
#9 6.795 Preparing metadata (setup.py): finished with status 'done'
#9 6.854 Collecting django-crispy-forms==1.14.0
#9 6.865 Downloading django_crispy_forms-1.14.0-py3-none-any.whl (133 kB)
#9 6.892 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.3/133.3 KB 5.6 MB/s eta 0:00:00
#9 6.972 Collecting django-extensions==3.1.5
#9 6.986 Downloading django_extensions-3.1.5-py3-none-any.whl (224 kB)
#9 7.020 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 224.2/224.2 KB 7.1 MB/s eta 0:00:00
#9 7.070 Collecting django-markdownx==3.0.1
#9 7.082 Downloading django_markdownx-3.0.1-py2.py3-none-any.whl (46 kB)
#9 7.097 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.0/46.0 KB 3.4 MB/s eta 0:00:00
#9 7.128 Collecting executing==0.8.2
#9 7.149 Downloading executing-0.8.2-py2.py3-none-any.whl (16 kB)
#9 7.192 Collecting ez-setup==0.9
#9 7.204 Downloading ez_setup-0.9.tar.gz (6.6 kB)
#9 7.219 Preparing metadata (setup.py): started
#9 7.910 Preparing metadata (setup.py): finished with status 'done'
#9 7.949 Collecting idna==3.3
#9 7.961 Downloading idna-3.3-py3-none-any.whl (61 kB)
#9 7.977 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 KB 4.4 MB/s eta 0:00:00
#9 8.068 Collecting importlib-metadata==4.11.2
#9 8.081 Downloading importlib_metadata-4.11.2-py3-none-any.whl (17 kB)
#9 8.210 Collecting ipython==8.0.1
#9 8.223 Downloading ipython-8.0.1-py3-none-any.whl (747 kB)
#9 8.318 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 747.5/747.5 KB 8.1 MB/s eta 0:00:00
#9 8.379 Collecting jedi==0.18.1
#9 8.392 Downloading jedi-0.18.1-py2.py3-none-any.whl (1.6 MB)
#9 8.586 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 8.2 MB/s eta 0:00:00
#9 8.656 Collecting Markdown==3.3.6
#9 8.670 Downloading Markdown-3.3.6-py3-none-any.whl (97 kB)
#9 8.690 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.8/97.8 KB 5.1 MB/s eta 0:00:00
#9 8.722 Collecting matplotlib-inline==0.1.3
#9 8.733 Downloading matplotlib_inline-0.1.3-py3-none-any.whl (8.2 kB)
#9 8.773 Collecting mypy-extensions==0.4.3
#9 8.786 Downloading mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
#9 8.830 Collecting oauthlib==3.2.0
#9 8.843 Downloading oauthlib-3.2.0-py3-none-any.whl (151 kB)
#9 8.869 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 151.5/151.5 KB 6.5 MB/s eta 0:00:00
#9 8.913 Collecting parso==0.8.3
#9 8.926 Downloading parso-0.8.3-py2.py3-none-any.whl (100 kB)
#9 8.948 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.8/100.8 KB 4.8 MB/s eta 0:00:00
#9 8.982 Collecting pathspec==0.9.0
#9 8.995 Downloading pathspec-0.9.0-py2.py3-none-any.whl (31 kB)
#9 9.038 Collecting pickleshare==0.7.5
#9 9.049 Downloading pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB)
#9 9.546 Collecting Pillow==9.0.1
#9 9.561 Downloading Pillow-9.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)
#9 10.10 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 8.0 MB/s eta 0:00:00
#9 10.16 Collecting platformdirs==2.5.1
#9 10.17 Downloading platformdirs-2.5.1-py3-none-any.whl (14 kB)
#9 10.26 Collecting prompt-toolkit==3.0.28
#9 10.27 Downloading prompt_toolkit-3.0.28-py3-none-any.whl (380 kB)
#9 10.32 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 380.2/380.2 KB 7.3 MB/s eta 0:00:00
#9 10.45 Collecting psycopg2==2.9.3
#9 10.46 Downloading psycopg2-2.9.3.tar.gz (380 kB)
#9 10.51 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 380.6/380.6 KB 7.8 MB/s eta 0:00:00
#9 10.61 Preparing metadata (setup.py): started
#9 11.43 Preparing metadata (setup.py): finished with status 'error'
#9 11.44 error: subprocess-exited-with-error
#9 11.44
#9 11.44 × python setup.py egg_info did not run successfully.
#9 11.44 │ exit code: 1
#9 11.44 ╰─> [23 lines of output]
#9 11.44 running egg_info
#9 11.44 creating /tmp/pip-pip-egg-info-8yc4rm15/psycopg2.egg-info
#9 11.44 writing /tmp/pip-pip-egg-info-8yc4rm15/psycopg2.egg-info/PKG-INFO
#9 11.44 writing dependency_links to /tmp/pip-pip-egg-info-8yc4rm15/psycopg2.egg-info/dependency_links.txt
#9 11.44 writing top-level names to /tmp/pip-pip-egg-info-8yc4rm15/psycopg2.egg-info/top_level.txt
#9 11.44 writing manifest file '/tmp/pip-pip-egg-info-8yc4rm15/psycopg2.egg-info/SOURCES.txt'
#9 11.44
#9 11.44 Error: pg_config executable not found.
#9 11.44
#9 11.44 pg_config is required to build psycopg2 from source. Please add the directory
#9 11.44 containing pg_config to the $PATH or specify the full executable path with the
#9 11.44 option:
#9 11.44
#9 11.44 python setup.py build_ext --pg-config /path/to/pg_config build ...
#9 11.44
#9 11.44 or with the pg_config option in 'setup.cfg'.
#9 11.44
#9 11.44 If you prefer to avoid building psycopg2 from source, please install the PyPI
#9 11.44 'psycopg2-binary' package instead.
#9 11.44
#9 11.44 For further information please check the 'doc/src/install.rst' file (also at
#9 11.44 <https://www.psycopg.org/docs/install.html>).
#9 11.44
#9 11.44 [end of output]
#9 11.44
#9 11.44 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 11.45 error: metadata-generation-failed
#9 11.45
#9 11.45 × Encountered error while generating package metadata.
#9 11.45 ╰─> See above for output.
#9 11.45
#9 11.45 note: This is an issue with the package mentioned above, not pip.
#9 11.45 hint: See above for details.
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1
```
현재 이런 상황인데 어떻게 하면 좋을까요??,,이제 곧 완성되가는데 막판에 에러가 터지니 속상하네요 ㅠㅜ
목록보기
sungyong 2 years, 8 months ago
안녕하세요. 아마도, psycopg2 때문인 것 같습니다.
requirements.txt 에서 psycopg2를 삭제하고 대신 psycopg2-binary 라고 입력해보세요.
Updated: March 9, 2022, 11:31 p.m.
KIM 1 year, 10 months ago
저도 같은 에러인데,
psycopg2-binary로 해도 안되고 있습니다...
Updated: Jan. 5, 2023, 9:09 p.m.
Leave a Comment: