0

I'm using Docker v 19. I have this at the end of my web/Dockerfile ...

FROM python:3.7-slim
  
RUN apt-get update && apt-get install

RUN apt-get install -y dos2unix
RUN apt-get install -y libmariadb-dev-compat libmariadb-dev
RUN apt-get update \
    && apt-get install -y --no-install-recommends gcc \
    && rm -rf /var/lib/apt/lists/*

RUN python -m pip install --upgrade pip

WORKDIR /app/

COPY requirements.txt requirements.txt
COPY entrypoint.sh entrypoint.sh
RUN tr -d '\r' < entrypoint.sh > /app/entrypoint2.sh
RUN ls /app/entrypoint2.sh
RUN ls /app/
RUN python -m pip install -r requirements.txt

RUN ls /app/entrypoint.sh
RUN dos2unix /app/entrypoint.sh
RUN ls /app/entrypoint.sh

RUN chmod +x /app/*.sh
RUN ls ./
ENTRYPOINT ["./entrypoint2.sh"]

However, when I run "docker-compose up" (which references the above), the "entrypoiet" file can't be found, which is baffling because the line above ("ls ./") shows that it exists ...

Step 14/19 : RUN ls /app/entrypoint.sh
 ---> Running in db8c11ce3fad
/app/entrypoint.sh
Removing intermediate container db8c11ce3fad
 ---> c23e69de2a86
Step 15/19 : RUN dos2unix /app/entrypoint.sh
 ---> Running in 9e5bbd1c0b9a
dos2unix: converting file /app/entrypoint.sh to Unix format...
Removing intermediate container 9e5bbd1c0b9a
 ---> 32a069690845
Step 16/19 : RUN ls /app/entrypoint.sh
 ---> Running in 8a53e70f219b
/app/entrypoint.sh
Removing intermediate container 8a53e70f219b
 ---> 5444676f45fb
Step 17/19 : RUN chmod +x /app/*.sh
 ---> Running in 5a6b295217c8
Removing intermediate container 5a6b295217c8
 ---> 8b5bfa4fd75a
Step 18/19 : RUN ls ./
 ---> Running in 9df3acb7deb7
entrypoint.sh
entrypoint2.sh
requirements.txt
Removing intermediate container 9df3acb7deb7
 ---> 009f8bbe18c8
Step 19/19 : ENTRYPOINT ["./entrypoint2.sh"]
 ---> Running in 41a7e28641a7
Removing intermediate container 41a7e28641a7
 ---> 34a7d4fceb8b

Successfully built 34a7d4fceb8b
Successfully tagged maps_web:latest
WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.

...
Creating maps_web_1   ... error

ERROR: for maps_web_1  Cannot start service web: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"./entrypoint2.sh\": stat ./entrypoint2.sh: no such file or directory": unknown

How do I tell Docker how to reference that entrypoint file? The docker-compose.yml file section including the above is below

  web:
    restart: always
    build: ./web
    ports:           # to access the container from outside
      - "8000:8000"
    env_file: .env
    environment:
      DEBUG: 'true'
    command: /usr/local/bin/gunicorn directory.wsgi:application --reload -w 2 -b :8000
    volumes:
    - ./web/:/app
    depends_on:
      - mysql
Dave
  • 15,639
  • 133
  • 442
  • 830
  • Can you include debugging steps to differentiate from similar questions? https://stackoverflow.com/search?q=%5Bdocker%5D+OCI+runtime+create+failed+no+such+file+or+directory&mixed=0 – BMitch Sep 27 '20 at 00:27
  • What is the very first line of the script? (Does that interpreter exist inside the image?) – David Maze Sep 27 '20 at 12:37
  • Hi @DavidMaze, edited question to include complete Dockerfile. First line is "FROM python:3.7-slim". – Dave Sep 27 '20 at 16:34
  • works for me. I copy/pasted your Dockerfile and created an empty requirements.txt, and made entrypoint.sh a simple shell script that prints and sleeps in an endless loop. I think @Al-waleed Shihadeh is correct, you will have better luck using absolute paths for everything. – Z4-tier Sep 27 '20 at 17:12
  • Are you on a Mac? What version of Docker are you using? – Dave Sep 27 '20 at 19:13

1 Answers1

1

Based on the provided Dockerfile and docker-compose file you are doing the following

  • Copy files (entrypoint + requirments) to /app
  • Install the needed packages
  • Start containers with the volume that overwrite the content of the /app, which is causing the issue.

To solve the issue you have to do one of the following

  • Copy all the data from ./web to the docker image and remove the volume

Dockerfile : add the following lines

WORKDIR /app/
COPY ./web /app

Docker-compose: remove the below lines

   volumes:
    - ./web/:/app
  • The second option is to change the path of the entry point so it does not conflict with the volume

Dockerfile

RUN tr -d '\r' < entrypoint.sh > /entrypoint2.sh
RUN chmod +x /entrypoint2.sh
ENTRYPOINT ["./entrypoint2.sh"]
Al-waleed Shihadeh
  • 2,697
  • 2
  • 8
  • 22
  • Tried your suggestion but it resulted in the error, 'ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/app/entrypoint2.sh\": stat /app/entrypoint2.sh: no such file or directory": unknown'. I edited my question to include the complete Dockerfile. I do have "WORKDIR /app/" right before all the action starts. – Dave Sep 27 '20 at 16:35
  • 1
    I found it , you are overwriting all the files under `/app` in your docker-compose file with this line ` volumes: - ./web/:/app`, This line will simply delete all the content in the /app and replace it with the content of your local './web' – Al-waleed Shihadeh Sep 27 '20 at 16:57
  • Thanks! I didn't fully understand how volumes worked. – Dave Sep 27 '20 at 20:09