我正在尝试从这个Dockerfile
运行一个码头映像
#!/bin/bash
FROM python:3.8.2
ENV PYTHONBUFFERED 1
ENV PYTHONWRITEBYTECODE 1
RUN apt-get update \
&& 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
---> 4f7cd4269fa9
Step 2/14 : ENV PYTHONBUFFERED 1
---> Running in 8a399ac58a4f
Removing intermediate container 8a399ac58a4f
---> 7b6eb9c0a10e
Step 3/14 : ENV PYTHONWRITEBYTECODE 1
---> Running in 5fd65310dc2a
Removing intermediate container 5fd65310dc2a
---> fce190ab48e4
Step 4/14 : RUN apt-get update && apt-get install -y netcat
---> 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
---> 143f03fec70e
Step 5/14 : ENV APP=/app
---> Running in 347068937f7f
Removing intermediate container 347068937f7f
---> acb56ad65301
Step 6/14 : WORKDIR $APP
---> Running in bfaf314d8f22
Removing intermediate container bfaf314d8f22
---> f33b9deb1f8a
Step 7/14 : COPY requirements.txt $APP
---> 784bf1406908
Step 8/14 : RUN pip install --upgrade pip
---> 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
---> 1ec7895d1c26
Step 9/14 : RUN pip install -r requirements.txt
---> 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: setuptools>=3.0 in /usr/local/lib/python3.8/site-packages (from gunicorn==20.0.4->-r requirements.txt (line 3)) (46.1.3)
Collecting urllib3<1.27,>=1.21.1
Downloading urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
Collecting certifi>=2017.4.17
Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Collecting idna<4,>=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 asgiref<4,>=3.3.2
Downloading asgiref-3.4.1-py3-none-any.whl (25 kB)
Collecting sqlparse>=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
---> da4d0aa605e4
Step 10/14 : COPY . $APP
---> 0c7a12fdfebe
Step 11/14 : EXPOSE 8000
---> Running in 6677507063c3
Removing intermediate container 6677507063c3
---> 34ff3d4a0102
Step 12/14 : RUN chmod +x /app/entrypoint.sh
---> Running in ac1d42ff7146
Removing intermediate container ac1d42ff7146
---> 88e76daf2dc4
Step 13/14 : ENTRYPOINT ["/app/entrypoint.sh"]
---> Running in 97e4e19308fc
Removing intermediate container 97e4e19308fc
---> de6f910d173e
Step 14/14 : CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "djangobackend.wsgi"]
---> Running in 44b53f9879ce
Removing intermediate container 44b53f9879ce
---> 61c4364ad29f
Successfully built 61c4364ad29f
Successfully tagged us.icr.io/capstone_project/dealership:latest
但是当我运行docker run
时,我得到了这样的信息:
standard_init_linux.go:211: exec用户进程导致"exec格式错误“
我正在开发ibmcloud在线实验室平台https://labs.cognitiveclass.ai
,这是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)
发布于 2021-11-16 17:59:11
好的,通过删除容器运行平稳的这个空间,我在entrypoint.sh文件中有了一个前导空间。
https://stackoverflow.com/questions/69966425
复制相似问题