#docker #dockerfile #docker-run
Вопрос:
Я пытаюсь запустить изображение докера из этого Dockerfile
:
#!/bin/bash FROM python:3.8.2 ENV PYTHONBUFFERED 1 ENV PYTHONWRITEBYTECODE 1 RUN apt-get update amp;amp; apt-get install -y netcat ENV APP=/app # Change the workdir. WORKDIR $APP # Install the requirements COPY requirements.txt $APP RUN pip install --upgrade pip RUN pip install -r requirements.txt # Copy the rest of the files COPY . $APP EXPOSE 8000 RUN chmod x /app/entrypoint.sh ENTRYPOINT ["/app/entrypoint.sh"] CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "djangobackend.wsgi"]
entrypoint.sh файл:
#!/bin/sh if [ "$DATABASE" = "postgres" ]; then echo "Waiting for postgres..." while ! nc -z $DATABASE_HOST $DATABASE_PORT; do sleep 0.1 done echo "PostgreSQL started" fi # Make migrations and migrate the database. echo "Making migrations and migrating the database. " python manage.py makemigrations main --noinput python manage.py migrate --noinput exec "$@"
это результат работы docker build
:
theia@theiadocker-amr56621:/home/project/agfzb-CloudAppDevelopment_Capstone/server$ docker build -t us.icr.io/capstone_project/dealership . Sending build context to Docker daemon 2.9MB Step 1/14 : FROM python:3.8.2 ---gt; 4f7cd4269fa9 Step 2/14 : ENV PYTHONBUFFERED 1 ---gt; Running in 8a399ac58a4f Removing intermediate container 8a399ac58a4f ---gt; 7b6eb9c0a10e Step 3/14 : ENV PYTHONWRITEBYTECODE 1 ---gt; Running in 5fd65310dc2a Removing intermediate container 5fd65310dc2a ---gt; fce190ab48e4 Step 4/14 : RUN apt-get update amp;amp; apt-get install -y netcat ---gt; Running in b295b4c16bd8 Get:1 http://deb.debian.org/debian buster InRelease [122 kB] Get:2 http://deb.debian.org/debian buster-updates InRelease [51.9 kB] Get:3 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB] Get:4 http://deb.debian.org/debian buster/main amd64 Packages [7906 kB] Get:5 http://deb.debian.org/debian buster-updates/main amd64 Packages [15.2 kB] Get:6 http://security.debian.org/debian-security buster/updates/main amd64 Packages [309 kB] Fetched 8469 kB in 2s (3987 kB/s) Reading package lists... Reading package lists... Building dependency tree... Reading state information... The following additional packages will be installed: netcat-traditional The following NEW packages will be installed: netcat netcat-traditional 0 upgraded, 2 newly installed, 0 to remove and 120 not upgraded. Need to get 75.9 kB of archives. After this operation, 156 kB of additional disk space will be used. Get:1 http://deb.debian.org/debian buster/main amd64 netcat-traditional amd64 1.10-41.1 [66.9 kB] Get:2 http://deb.debian.org/debian buster/main amd64 netcat all 1.10-41.1 [9034 B] debconf: delaying package configuration, since apt-utils is not installed Fetched 75.9 kB in 0s (286 kB/s) Selecting previously unselected package netcat-traditional. (Reading database ... 24602 files and directories currently installed.) Preparing to unpack .../netcat-traditional_1.10-41.1_amd64.deb ... Unpacking netcat-traditional (1.10-41.1) ... Selecting previously unselected package netcat. Preparing to unpack .../netcat_1.10-41.1_all.deb ... Unpacking netcat (1.10-41.1) ... Setting up netcat-traditional (1.10-41.1) ... update-alternatives: using /bin/nc.traditional to provide /bin/nc (nc) in auto mode Setting up netcat (1.10-41.1) ... Removing intermediate container b295b4c16bd8 ---gt; 143f03fec70e Step 5/14 : ENV APP=/app ---gt; Running in 347068937f7f Removing intermediate container 347068937f7f ---gt; acb56ad65301 Step 6/14 : WORKDIR $APP ---gt; Running in bfaf314d8f22 Removing intermediate container bfaf314d8f22 ---gt; f33b9deb1f8a Step 7/14 : COPY requirements.txt $APP ---gt; 784bf1406908 Step 8/14 : RUN pip install --upgrade pip ---gt; Running in c445d03e82a5 Collecting pip Downloading pip-21.3.1-py3-none-any.whl (1.7 MB) Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 20.1 Uninstalling pip-20.1: Successfully uninstalled pip-20.1 Successfully installed pip-21.3.1 Removing intermediate container c445d03e82a5 ---gt; 1ec7895d1c26 Step 9/14 : RUN pip install -r requirements.txt ---gt; Running in 45c4500742ef Collecting requests Downloading requests-2.26.0-py2.py3-none-any.whl (62 kB) Collecting Django Downloading Django-3.2.9-py3-none-any.whl (7.9 MB) Collecting gunicorn==20.0.4 Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB) Collecting Pillow==8.0.1 Downloading Pillow-8.0.1-cp38-cp38-manylinux1_x86_64.whl (2.2 MB) Requirement already satisfied: setuptoolsgt;=3.0 in /usr/local/lib/python3.8/site-packages (from gunicorn==20.0.4-gt;-r requirements.txt (line 3)) (46.1.3) Collecting urllib3lt;1.27,gt;=1.21.1 Downloading urllib3-1.26.7-py2.py3-none-any.whl (138 kB) Collecting certifigt;=2017.4.17 Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB) Collecting idnalt;4,gt;=2.5 Downloading idna-3.3-py3-none-any.whl (61 kB) Collecting charset-normalizer~=2.0.0 Downloading charset_normalizer-2.0.7-py3-none-any.whl (38 kB) Collecting pytz Downloading pytz-2021.3-py2.py3-none-any.whl (503 kB) Collecting asgireflt;4,gt;=3.3.2 Downloading asgiref-3.4.1-py3-none-any.whl (25 kB) Collecting sqlparsegt;=0.2.2 Downloading sqlparse-0.4.2-py3-none-any.whl (42 kB) Installing collected packages: urllib3, sqlparse, pytz, idna, charset-normalizer, certifi, asgiref, requests, Pillow, gunicorn, Django Successfully installed Django-3.2.9 Pillow-8.0.1 asgiref-3.4.1 certifi-2021.10.8 charset-normalizer-2.0.7 gunicorn-20.0.4 idna-3.3 pytz-2021.3 requests-2.26.0 sqlparse-0.4.2 urllib3-1.26.7 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv Removing intermediate container 45c4500742ef ---gt; da4d0aa605e4 Step 10/14 : COPY . $APP ---gt; 0c7a12fdfebe Step 11/14 : EXPOSE 8000 ---gt; Running in 6677507063c3 Removing intermediate container 6677507063c3 ---gt; 34ff3d4a0102 Step 12/14 : RUN chmod x /app/entrypoint.sh ---gt; Running in ac1d42ff7146 Removing intermediate container ac1d42ff7146 ---gt; 88e76daf2dc4 Step 13/14 : ENTRYPOINT ["/app/entrypoint.sh"] ---gt; Running in 97e4e19308fc Removing intermediate container 97e4e19308fc ---gt; de6f910d173e Step 14/14 : CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "djangobackend.wsgi"] ---gt; Running in 44b53f9879ce Removing intermediate container 44b53f9879ce ---gt; 61c4364ad29f Successfully built 61c4364ad29f Successfully tagged us.icr.io/capstone_project/dealership:latest
но когда я бегу docker run
, я получаю это:
standard_init_linux.go:211: пользовательский процесс exec вызвал «ошибку формата exec»
я работаю над онлайн-лабораторной платформой https://labs.cognitiveclass.ai
ibmcloud, которая является x86_64
архитектурой.
вот как выглядит мой рабочий каталог:
theia@theiadocker-amr56621:/home/project/agfzb-CloudAppDevelopment_Capstone/server$ ls db.sqlite3 djangobackend kubectl Procfile deployment.yml Dockerfile manage.py requirements.txt djangoapp entrypoint.sh manifest.yml static
это результат docker run
работы в подробном режиме:
2021-11-14T19:58:16.446645598Z container create d4fca21da125d980f1b417b48ebc031f0d9d1e79038209bfd5fe260dc2bedb47 (image=61c43, name=cranky_einstein) 2021-11-14T19:58:16.490786010Z container attach d4fca21da125d980f1b417b48ebc031f0d9d1e79038209bfd5fe260dc2bedb47 (image=61c43, name=cranky_einstein) 2021-11-14T19:58:16.543087848Z network connect 89fb46b849c45c9bb7e25e634633cc4e917e6e52591c67abd5a994d5f067909f (container=d4fca21da125d980f1b417b48ebc031f0d9d1e79038209bfd5fe260dc2bedb47, name=bridge, type=bridge) standard_init_linux.go:211: exec user process caused "exec format error" 2021-11-14T19:58:17.419528824Z container start d4fca21da125d980f1b417b48ebc031f0d9d1e79038209bfd5fe260dc2bedb47 (image=61c43, name=cranky_einstein) 2021-11-14T19:58:17.488776378Z container die d4fca21da125d980f1b417b48ebc031f0d9d1e79038209bfd5fe260dc2bedb47 (exitCode=1, image=61c43, name=cranky_einstein) 2021-11-14T19:58:17.650094624Z network disconnect 89fb46b849c45c9bb7e25e634633cc4e917e6e52591c67abd5a994d5f067909f (container=d4fca21da125d980f1b417b48ebc031f0d9d1e79038209bfd5fe260dc2bedb47, name=bridge, type=bridge)
Ответ №1:
Хорошо, у меня было ведущее место в entrypoint.sh файл, удалив это пространство, контейнер будет работать бесперебойно.