简体   繁体   English

Docker enrtypiont 在 django 应用程序上找不到 alpine python

[英]Docker enrtypiont not found on django app with alpine python

This is my Dockerfile:这是我的 Dockerfile:

FROM python:alpine3.17

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

WORKDIR /app

# install psycopg2 dependencies
RUN apk update \
    && apk add postgresql-dev gcc python3-dev musl-dev

COPY Pipfile /app
COPY Pipfile.lock /app
RUN pip install pipenv
RUN pipenv install --system

COPY . /app


USER root
RUN chmod +x /app/entrypoint-prod.sh
ENTRYPOINT ["/app/entrypoint-prod.sh"]

This is my entrypoint-prod.sh这是我的入口点-prod.sh

#!/bin/bash

# Apply migrations
python manage.py migrate --noinput

# Collect static
python manage.py collectstatic --no-input --clear

# Start the application
gunicorn grayti_backend.wsgi:application --bind 0.0.0.0:8000 --workers 3

When I run the image docker run -it myapp:latest , this is the output:当我运行图像docker run -it myapp:latest时,这是 output:

exec /app/entrypoint-prod.sh: no such file or directory

This error occured only when I moved from FROM python:3.10 to FROM python:alpine3.17只有当我从FROM python:3.10移动到FROM python:alpine3.17时才会出现此错误

I tried the following but didn't work also:我尝试了以下但也没有用:

USER root
RUN chmod +x entrypoint-prod.sh
ENTRYPOINT ["./entrypoint-prod.sh"]

The answer from Hans Kilian solved my problem. Hans Kilian的回答解决了我的问题。 The problem was solved by replacing #!/bin/bash with #!/bin/sh in the entrypoint-prod.sh file.通过在entrypoint-prod.sh文件中用 #!/bin/sh 替换 #!/bin/bash 解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM