Docker-Compose:安装时找不到entrypoint.sh

问题描述 投票:0回答:0

我正在尝试使用 Django 服务构建一个撰写文件,其中每个服务都有一个入口点来执行迁移,但是当我挂载我的目录时,docker 无法找到entrypoint.sh,但当我不挂载时它可以工作。

容器显示此错误

exec /code/dev/point.sh: no such file or directory

docker文件

FROM python:3.11-slim-bullseye

WORKDIR /code


COPY req.txt .
RUN pip3 install -r req.txt --no-cache-dir



COPY ./dev/entrypoint.sh ./dev/
RUN sed -i 's/\r$//g' ./dev/entrypoint.sh
RUN chmod +x ./dev/entrypoint.sh
# Convert line endings to Unix-style (LF)
RUN apt-get update && apt-get install -y dos2unix && dos2unix ./dev/entrypoint.sh && chmod +x ./dev/entrypoint.sh

COPY . .

ENTRYPOINT ["/code/dev/entrypoint.sh"]


CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

compose.yaml

services:

  auth:
    build:
      context: ./Auth
      dockerfile: dev/dockerfile
    container_name: Auth
    env_file:
      - "./Auth/Auth/.env"
    ports:
      - 8001:8000
    expose:
      - 8001
    networks:
      - backend

    volumes:
      - ./Auth:/code

  artifact:
    build:
      context: ./Artifact
      dockerfile: dev/dockerfile
    container_name: Artifact
    env_file:
      - "./Artifact/Artifact/.env"
    ports:
      - 8002:8000
    expose:
      - 8002
    networks:
      - backend
    volumes:
      - ./Artifact:/code


networks:
  backend:

入口点.sh

#!/bin/sh
# entrypoint.sh
python manage.py makemigrations
# Run migrations
python manage.py migrate

# Then run the main container command (passed to us as arguments)
exec "$@"

docker内部的目录结构:

django docker docker-compose dockerfile entry-point
© www.soinside.com 2019 - 2024. All rights reserved.