Big thank to this tutorial. I can finally understand every line in both dockerfile and docker compose. Other youtube videos I've watched don't go that detailed and clear. Thank you so much!!
Sir, you are really really good at teaching. I mean really good. Of all the youtube videos I watch (and I watch a lot), you're in my top 3 youtuber on tech tools ! Thank you sir !
I love your docker series and others, but I have a problem, I hope you can guide us on that as well. I am new to Docker, checked some tutorials for the understanding, but unfortunatelly I am not understanding one thing and that is: 1- How to use the Docker image with the prespective of development? I understand that we can make the docker image and push that to docker-hub repository, but don’t what to do after that. I pulled the docker image from docker-hub which I pushed. At this point I am missing what can I do with this image and how to do that? For Example: 1- Created a Django app 2- Created a Dockerfile 3- Created the docker-compose.yml file 4- Build the docker image with “docker-compose build” (on Windows 10) 5- Ran the image with “docker-compose up”. 6- Up until this point, everything went well and I can access the application from my browser. 7- Then I pushed this image to docker-hub and I can see the pushed image on the repository. 8- At this point I pulled the code at another machine that is running Ubuntu 20.04 and tried to run the docker. (no output) 9- Now I am confused here, what should I do with this docker image which I pulled from docker-hub? Where is my source code of Django App? How can I work etc. I am new to docker, please help. Thanks.
Hi, thanks a lot for this tutorial! You explain it in a great way. There is one point I did't get. Why should I run the "docker-compose run --rm app django-admin startproject core." command? Why not without docker-compose like in Part 1? The content of the folder will by copied to the container anyway, isn' it?
Let me know if this doesn't make sense. The docker-compose run --rm app django-admin startproject core. command is used with Docker Compose to run a one-off command inside a service. This command is specifically designed for situations where you want to run a command in a Docker container defined in your docker-compose.yml file. The purpose of using docker-compose run in this context is to ensure that the command (django-admin startproject core.) is executed within the context of your Docker container. This ensures that the project structure and files created by the startproject command are within the Docker container and not on your local machine. If you were to run the django-admin startproject core. command directly on your local machine without docker-compose, the project structure and files would be created on your local machine, outside the Docker container. This might lead to compatibility issues, especially if your development environment relies on dependencies, configurations, or tools that are specific to the Docker container. By using docker-compose run --rm app, you explicitly specify the service (app in this case) where the command should be executed. The --rm flag ensures that the container is removed after the command completes.
Thanks a lot for that very detailed answer. I’m quite new to Django and Docker. Your answers makes totally sense if I imagine that the django-admin command does slightly different things, if I runs inside or outside the container.
Awesome sir, but my question is how to run multiple commands for existing project like makemigrations, migrate, runserver for existing project please answer
I have the same problem as some others in this comment section: when i run `docker-compose run --rm app django-admin startproject core .` the django project doesn't get created. I am on MacOS and have tried it both with and without venv. EDIT: I had not saved some files in VSCode. Once I did file => save all and ran build and run again, it worked.
Hi, Thank you so much for the such complete explantory video. I have run the app successfully but facing another issue. When ever I try to use a class from Django or DRF, vscode can't auto import or show the option to import that class from django/drf module. This is really annoying after setting up the project. Kindly create a video on this issue or if there is already a video please send the link Thanks :-)
to all those getting no file generated after running docker compose run, this is because the Dockerfile specifies working directory to be "/app" whereas, docker-compose.yml file specifies the working dir to be "/django". so it does not work. the easy fix is to edit your docker-compose.yml file and change the volume to mount in /app dir: - .:/app
Hi and thanks a lot for yet another amazing tutorial! One question if I might, why are we specifying the command to create a new Django "core" App on the CLI with the docker-compose run command and we are not placing it in the command: line inside the docker-compose.yml file? Couldn't we chain this command and the run server command there and avoid passing it manually? Thanks!
i had the issue where $docker-compose run --rm app django-admin startproject core . didn't work to create a core folder! I fixed it by changing the working directory in the docker file from /app to /django. You have to delete the container image in docker before trying the command again! hope this helps.
Hey Mate, best tutorials ever I might say. But I do get "Run a one-off command on a service." when running docker-compose build. It doesn´t create core . Any ideias why? thanks
i had the same issue but fixed it by changing the working directory in the docer file from /app to /django. You have to delete the container image in docker before trying the command again! hope this helps.
Thank you for good lesson. As I follow your lecture, I have some trouble with starting a django project. I can't see the "core" forlder created after the following command. I also don't see any error message. [docker-compose run --rm app django-admin startproject core . ] Could you give me some advice on that?
is it possible to avoid using runserver on windows? what if you use WSL and download a linux app on windows, then you could download uswgi and other libraries that aren't available on windows. I don't understand enough to know what's possible on windows or what limitations there are
the new app "core" does not generate after running the command "docker-compose run ---rm app django-admin startproject core .". Any idea for the reason?
@@veryacademy Found it. Seems it causes because my project was on a removable drive and it seems to require the project to be on the hard drive. Not sure why though, but it worked when the files moved to the hard drive folder and then run after a docker prune.
There appears to be an issue - when using django-compose run --rm django-admin startproject core . nothing happens. It does not create a django project. A few other commenters have had the same issue. Are you running in a venv? From your CLI, it doesn't seem to be the case.