작성
·
503
0
안녕하세요.
강의를 차근차근 따라하는 중인데
도커를 처음 써봐서 어려움이 많습니다 ㅠㅠ
새로 작성한 도커 파일을 업로드하여
django_test_image:4 이미지를 생성하려는데
다음과 같은 오류가 납니다.
Step 1/12 : FROM python:3.9.0
---> 0affb4652fc0
Step 2/12 : WORKDIR /home/
---> Using cache
---> ed1dec168426
Step 3/12 : RUN echo "testing"
---> Running in b1219dc0f983
testing
Removing intermediate container b1219dc0f983
---> 834d6a4783ee
Step 4/12 : RUN git clone https://github.com/kim1210/pragmatic.git
---> Running in d3c69af71289
Cloning into 'pragmatic'...
Removing intermediate container d3c69af71289
---> 369d04f7e380
Step 5/12 : WORKDIR /home/pragmatic/
---> Running in d13a6faf5dcf
Removing intermediate container d13a6faf5dcf
---> f12a028facd7
Step 6/12 : RUN pip install -r requirements.txt
---> Running in 1a5e051898d0
Collecting asgiref==3.4.1
Downloading asgiref-3.4.1-py3-none-any.whl (25 kB)
Collecting beautifulsoup4==4.9.3
Downloading beautifulsoup4-4.9.3-py3-none-any.whl (115 kB)
Collecting Django==3.2.5
Downloading Django-3.2.5-py3-none-any.whl (7.9 MB)
Collecting django-bootstrap4==3.0.1
Downloading django_bootstrap4-3.0.1-py3-none-any.whl (24 kB)
Collecting django-environ==0.4.5
Downloading django_environ-0.4.5-py2.py3-none-any.whl (21 kB)
Collecting gunicorn==20.1.0
Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
Requirement already satisfied: setuptools>=3.0 in /usr/local/lib/python3.9/site-packages (from gunicorn==20.1.0->-r requirements.txt (line 6)) (50.3.2)
Collecting Pillow==8.3.1
Downloading Pillow-8.3.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (3.0 MB)
Collecting pytz==2021.1
Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting soupsieve==2.2.1
Downloading soupsieve-2.2.1-py3-none-any.whl (33 kB)
Collecting sqlparse==0.4.1
Downloading sqlparse-0.4.1-py3-none-any.whl (42 kB)
Installing collected packages: sqlparse, soupsieve, pytz, asgiref, Django, beautifulsoup4, Pillow, gunicorn, django-environ, django-bootstrap4
Successfully installed Django-3.2.5 Pillow-8.3.1 asgiref-3.4.1 beautifulsoup4-4.9.3 django-bootstrap4-3.0.1 django-environ-0.4.5 gunicorn-20.1.0 pytz-2021.1 soupsieve-2.2.1 sqlparse-0.4.1
WARNING: You are using pip version 20.3.1; however, version 21.2.4 is available. You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Removing intermediate container 1a5e051898d0
---> 1fe1d6fbb1b2
Step 7/12 : RUN pip install gunicorn
---> Running in 28ddb9af28e8
Requirement already satisfied: gunicorn in /usr/local/lib/python3.9/site-packages (20.1.0)
Requirement already satisfied: setuptools>=3.0 in /usr/local/lib/python3.9/site-packages (from gunicorn) (50.3.2)
WARNING: You are using pip version 20.3.1; however, version 21.2.4 is available. You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Removing intermediate container 28ddb9af28e8
---> a3cf36aa787a
Step 8/12 : RUN pip install mysqlclient
---> Running in 502b5663f1cf
Collecting mysqlclient
Downloading mysqlclient-2.0.3.tar.gz (88 kB)
Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (setup.py): started
Building wheel for mysqlclient (setup.py): finished with status 'done'
Created wheel for mysqlclient: filename=mysqlclient-2.0.3-cp39-cp39-linux_x86_64.whl size=116175 sha256=1e80a1d09d83c4b1b51bd5fb5f9f56f68685784ab7b5bff2c966271a98c7009e
Stored in directory: /root/.cache/pip/wheels/43/55/d9/a2243d4b624c18c5cba30bf88e0521147498368068cb302532
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.0.3
WARNING: You are using pip version 20.3.1; however, version 21.2.4 is available. You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Removing intermediate container 502b5663f1cf
---> 3975c0b1cd41
Step 9/12 : RUN echo "SECRET_KEY=django-insecure-_(oh=5n^xsedxynf5@(6_1)y!11+p7a^o5q%p-_c#0ya#h_*55" > .env
---> Running in 50eab4dfb9f5
Removing intermediate container 50eab4dfb9f5
---> 9692e8a6ae50
Step 10/12 : RUN python manage.py collectstatic
---> Running in f2effc16fe7c
Unknown command: 'collectstatic' Type 'manage.py help' for usage.
The command '/bin/sh -c python manage.py collectstatic' returned a non-zero code: 1
collectstatic 부분에서 에러가 나는 것 같은데요.
작성한 도커 파일도 함께 올립니다.
FROM python:3.9.0
WORKDIR /home/
RUN echo "testing"
RUN git clone https://github.com/kim1210/pragmatic.git
WORKDIR /home/pragmatic/
RUN pip install -r requirements.txt
RUN pip install gunicorn
RUN pip install mysqlclient
RUN echo "SECRET_KEY=django-insecure-_(oh=5n^xsedxynf5@(6_1)y!11+p7a^o5q%p-_c#0ya#h_*55" > .env
RUN python manage.py collectstatic
EXPOSE 8000
CMD ["bash", "-c", "python manage.py migrate --settings=pragmatic.settings.deploy && gunicorn pragmatic.wsgi --env DJANGO_SETTINGS_MODULE=pragmatic.settings.deploy --bind 0.0.0.0:8000"]
답변 1
1
안녕하세요.
질문 확인했습니다.
질문을 확인하긴 했는데..
해당 문제는 처음 보는 에러네요.
분명 manage.py 파일도 있고 정상적으로 구동되어야 하는 것 같은데,
collectstatic 명령어 자체를 인식을 못하고 있는것 같습니다.
일단 비슷한 사례를 찾아보았습니다.
export DJANGO_SETTINGS_MODULE=mysite.settings
라는 명령어를 사용했더니 정상적으로 작동되었다고 질문자가 답변을 남겼습니다.
한번 Dockerfile 의 collectstatic 명령 앞에
RUN export DJANGO_SETTINGS_MODULE=pragmatic.settings
구문을 넣으신 이후 다시 한번 시도해보시길 바랍니다.
그럼에도 되지 않는다면 계속 질문 남겨주세요.
좋은하루 보내시구요!
감사합니다-
해결하였습니다. settings 관련 파일에서 오류가 있었습니다.ㅠㅠ 답변 감사합니다.