bobby-didcoding / drf_course

Django Rest Framework Course
261 stars 237 forks source link

Dockerfile misconfiguration #4

Open WulffenSec opened 1 year ago

WulffenSec commented 1 year ago

Hey I don't know if this is a linux issue or may happen in windows too but the docker-compose -d up --build is throwing a: "Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/code/docker/entrypoints/entrypoint.sh": permission denied: unknown"

Solution: A simple change in "backend/docker/docker_files/Dockerfile" last line from: ENTRYPOINT [ "/code/docker/entrypoints/entrypoint.sh"] To: ENTRYPOINT ["bash", "-e", "/code/docker/entrypoints/entrypoint.sh"] Solves the issue. Hope it helps!

Tez01 commented 1 year ago

Hi, Yes I was facing the same issue in PopOS. Your solution worked for me. Thanks

leni1 commented 1 year ago

Thanks so much @WulffenSec for creating this issue 🙌🏿 I also ran into this problem and your solution removed the issue for me. Running on KDE neon 5.26

tharanseriously commented 1 year ago

Hi @WulffenSec im having another issue after replacing the code as you suggested.

2023-03-15 17:14:17 Unknown command: 'makemigrations\r'. Did you mean makemigrations? 2023-03-15 17:14:17 Type 'manage.py help' for usage.

Basically it's running the container but when it hits the entrypoint.sh file for some reason its running 'makemigrations\r' instead of just 'makemigrations'

here is what's in my entrypoint.sh(which I have not made a change to btw) #!/bin/sh python manage.py makemigrations python manage.py migrate python manage.py test exec "$@"

hoping someone can help with this thank you

WulffenSec commented 1 year ago

Haven't had that issue, \r is new line in bash, did you try to run the the "python manage.py makemigrations" manually? instead of using the shell script?

bobby-didcoding commented 1 year ago

Running the migration commands in the terminal should work. This is assuming, of course, that the container is running.

If the build fails, remove the migration commands from the entry point file but leave everything else.

If you have good eyes, you can use the terminal in docker desktop to run any Django management company I.e. python manage.py collectstatic

Another option is to enter the container via you text editor.

docker exec -it bash

🙌

joedady16 commented 1 year ago

Hi all, I'm having the below error after running the docker build 2023-03-24 16:43:51 exec /code/docker/entrypoints/entrypoint.sh: no such file or directory

Any thoughts?

WulffenSec commented 1 year ago

@joedady16 Does even exist "/backend/docker/entrypoints/entrypoint.sh" in your drf_course folder? if not git pull

joedady16 commented 1 year ago

@WulffenSec yeah its in there. Kind of why i'm confused. I even did what the others did for their error with no change. My app runs but i get that error on my api

3k3n3 commented 1 year ago

In addition to @WulffenSec 's solution to the Unknown command: 'makemigrations\r'. Did you mean makemigrations?... error, You can also edit your script to this #!/bin/sh python manage.py makemigrations && python manage.py migrate && python manage.py test && exec "$@"

WulffenSec commented 1 year ago

@joedady16 , maybe try to give it the full path from root?

Allan1212 commented 1 year ago

@joedady16 I'm having the same issue; confirmed the directory I'm running docker-compose from is the main drf_course folder and I'm outside the venv, I deleted and rebuilt the Docker apps multiple times, still get the API error. @WulffenSec I also updated the /backend/docker/docker_files/Dockerfile prior to Docker build to have the full path from C: to the entrypoint.sh (within both the ENTRYPOINT brackets and after the chmod command), is this where you're referring to?

I'm only 1.5yrs into software dev and Docker is new to me, I'm sure I'm doing something wrong here. Very grateful for any help!

bobby-didcoding commented 1 year ago

Hi mate.

Try changing the entrypoint line to:

CMD ['python','manage.py','makemigrations']

Hope this helps

Allan1212 commented 1 year ago

@bobby-didcoding you definitely made today a Good Friday as that cleared the error and got it to run, thank you very much! :)

jackielics commented 1 year ago

Hi @WulffenSec im having another issue after replacing the code as you suggested.

2023-03-15 17:14:17 Unknown command: 'makemigrations\r'. Did you mean makemigrations? 2023-03-15 17:14:17 Type 'manage.py help' for usage.

Basically it's running the container but when it hits the entrypoint.sh file for some reason its running 'makemigrations\r' instead of just 'makemigrations'

here is what's in my entrypoint.sh(which I have not made a change to btw) #!/bin/sh python manage.py makemigrations python manage.py migrate python manage.py test exec "$@"

hoping someone can help with this thank you

Thank you @tharanseriously