I deleted the first attempt at the drf_course tutorial.
downloaded Docker Desktop and started the drf_course tutorial again. Starting at module_1.
issued docker-compose up -d --build. Completed fine.
In the docker desktop, the api-1 container is not running. The log file has the message
"/code/docker/entrypoints/entrypoint.sh: no such file or directory"
When I go into the container for api-1, and click on Files tab, I can see the linux enviroment. The file tree looks correct. entrypoint.sh is in the tree code/docker/entrypoints/entrypoint.sh.
Since I could not get the dockerized container to work, I tried using curl.
First, I re-activated the virtual environment (venv\Scripts\activate.bat).
Then I changed to the backend folder.
Then I started the django server python manage.py runserver
Then I opened another terminal in order to post the curl command provided at end of module_3 step file.
curl -X POST -H "Content-type: application/json" -d '{"name": "Bobby Stearman", "message": "test", "email":"[email protected]"}' 'http://api:8000/contact/'
However, the above curl command failed. It thought I had an unmatched curly brace.
After googling, I edited the above curl command to use double quotes instead of single quotes...
curl -X POST -H "Content-type: application/json" -d "{"name": "Bobby Stearman", "message": "test", "email":"[email protected]"}" "http://localhost:8000/contact/"
The above command worked. Notice I used localhost in the url.
Obviously, my local code is correct. However, the docker containerized code does not work (as described above). This is the problem with Docker. It is supposed to ensure that a project will work exactly the same on every machine. This is an example of where it doe s not.
I suspect I am not the only person who had this problem. Please do not sweep it under the rug. Have another tutorial specifically on this issue.
***Still trying to figure out why the api-1 process does not start in the Docker container. So here is what I did...
I started a new drf_course folder (saved the old 1 to a different folder name). I downloaded module_4 from the git repository. But module_4 is not complete. There are things that need to be done to make it complete. Here is what I did to make it complete...
1)create venv (virtual environment)
2)activate venv
3)copy env.template .env
4)pip install -r backend/requirements.txt
5)makemigrations
6)migrate
At this point I deactivated the venv.
Changed directory to the root directory (drf_course)
ran docker-compose up -d --build.
docker ran fine.
Start Docker Desktop.
Same problem as before. api-1 will not start. Log files has "exec /code/docker/entrypoints/entrypoint.sh: no such file or directory"
At this point I am pretty certain that problem is either with my version of Docker Desktop (4.18) or the project has not been dockerized correctly.
As a check, I did run the curl command, and that does work.
bobby there is a very easy way to troubleshoot this problem. If you get a chance, please download a current version of Docker Desktop (4.18) and then run the docker-compose command at the end of module_3. I would love to know if it works.
FMR