Why my docker Fail "exec /usr/src/app/entrypoint.sh: no such file or directory"?

410 views Asked by At

I'm trying to run container in docker with windows 11. When I'm running docker compose up web server, it shows exec ./entrypoint.sh: no such file or directory, but it does exist in folder, and it also shows in web container files.

And the db container is running and worked.

docker-compose.yml:

version: "3"
services:
  db:
    environment:
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=db
    image: postgres:14.0-alpine
    ports:
      - 5442:5432
  web:
    environment:
      - [email protected]
      - GMAIL_PASSWORD=gmailpassword
    build: ./
    command: python manage.py runserver 0.0.0.0:8080
    volumes:
      - ./:/usr/src/app/
    ports:
      - 80:8080
    env_file:
      - ./.env
    depends_on:
      - db

Dockerfile:

# pull official base image
FROM python:3.7-alpine

# set work directory
WORKDIR /usr/src/app

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN apk update \
    && apk add postgresql-dev gcc python3-dev musl-dev jpeg-dev zlib-dev make
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt /usr/src/app/requirements.txt
RUN pip install -r requirements.txt

# copy project
COPY . /usr/src/app/
COPY ./entrypoint.sh /usr/src/app/entrypoint.sh
RUN chmod +x /usr/src/app/entrypoint.sh
# run entrypoint.sh
EXPOSE 80
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]

entrypoint:

#!/bin/sh
# python manage.py flush --no-input
python manage.py makemigrations
python manage.py migrate
if [ $ENV = "prod" ]; then python manage.py collectstatic --no-input; fi
python manage.py loaddata */fixtures/*.json
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.filter(email='admin@domain').exists() or User.objects.create_superuser('admin@domain', 'password')" | python manage.py shell
exec "$@"

Thank you for your help!

I tried to:

  1. docker exec -it <container_name_or_id> sh, but can't be entry because container not running.
  2. docker run -v /local/path/to/entrypoint.sh:/usr/src/app/entrypoint.sh my_image, but I still get exec /usr/src/app/entrypoint.sh: no such file or directory
0

There are 0 answers