运行 docker-compose up –build 时,我总是遇到此错误消息。任何人都知道我对 docker-entrypoint 文件做错了什么?
ERROR: for 986991ccdfe1_ubercoach_web_1 Cannot start service web: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./docker-entrypoint.sh\": permission denied": unknown
ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./docker-entrypoint.sh\": permission denied": unknown
ERROR: Encountered errors while bringing up the project.
码头工人撰写:
version: '3'
services:
db:
image: postgres
ports:
- "5432:5432"
web:
build: .
entrypoint: ./docker-entrypoint.sh
env_file: .env
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
Dockerfile:
从 python:3 中拉取基础镜像
# Set environment varibles
ENV PYTHONUNBUFFERED 1
# Set work directory
RUN mkdir /code
WORKDIR /code
# Install dependencies
RUN pip install --upgrade pip
RUN pip install pipenv
COPY ./Pipfile /code/Pipfile
RUN pipenv install --deploy --system --skip-lock --dev
# Copy project
COPY . /code/
码头入口点.sh
#!/bin/bash
# Collect static files
echo "Collect static files"
python manage.py collectstatic --noinput
# Apply database migrations
echo "Apply database migrations"
python manage.py migrate
# Start server
echo "Starting server"
python manage.py runserver 0.0.0.0:8000
原文由 Joey Coder 发布,翻译遵循 CC BY-SA 4.0 许可协议
我猜你的
docker-entrypoint.sh
没有执行权限(x
)。而且docker-compose.yml
并不是docker-entrypoint.sh
的最佳位置。这是覆盖设置,请参见 entrypoint 。默认值应该放在Dockerfile
中。尝试这个:将此添加到您的末尾
Dockerfile
docker-entrypoint.sh
应该与Dockerfile
位于同一文件夹中(或调整COPY
路径)。从 --- 中删除entrypoint
docker-compose.yml
。重建,重新运行。