Docker-compose无法在ubuntu20.04上运行[权限被拒绝entrypoint.sh]

k2fxgqgv  于 2023-03-01  发布在  Docker
关注(0)|答案(1)|浏览(373)

我的docker-compose工作正常,运行在Windows 10上,但当我试图从ubuntu 20.04运行它时,我得到这个错误:

ERROR: for container_web_1  Cannot start service web: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/usr/src/app/entrypoint.sh": permission denied: unknown

ERROR: for web  Cannot start service web: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/usr/src/app/entrypoint.sh": permission denied: unknown
ERROR: Encountered errors while bringing up the project.

我不明白为什么我得到Permission deniedentrypoint.sh?我用chmod +x来避免这个...
我的Dockerfile

FROM python:3.10.0-alpine
WORKDIR /usr/src/app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN pip install --upgrade pip
RUN apk update
RUN apk add postgresql-dev gcc python3-dev musl-dev
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY entrypoint.sh .
RUN sed -i 's/\r$//g' /usr/src/app/entrypoint.sh
RUN chmod +x /usr/src/app/entrypoint.sh
COPY .. .
ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $HOME
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
COPY .. $APP_HOME
RUN mkdir $APP_HOME/staticfiles
RUN mkdir $APP_HOME/mediafiles
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]
0g0grzrc

0g0grzrc1#

您的Dockerfile有问题。在您创建entrypoint.sh并执行chmod +x之后,您会使用COPY .. .覆盖权限。解决此问题的一种方法是将RUN chmod +x /usr/src/app/entrypoint.sh行放在最后,正好在ENTRYPOINT之前。

相关问题