I tried this to learn a bit about docker. I don't think I understand how it is supposed to work.
When I first went through the steps I've got an error:
djangoapp | File "/app/djangoproject/urls.py", line 21, in <module>
djangoapp | path('users/', include('djangoapp.urls')),
djangoapp | NameError: name 'include' is not defined
Which is pretty obvious, I forgot to import include, my issue is I don't know how to update the code in the container.
I would expect rebuilding should fix that, but it doesn't.
docker compose up --build
I have also tried to remove everything and retrace my steps.
That's exactly how I tried to fix that. I have that code in my project folder, but no matter what I do the container seems to be stuck with the old code.
Do I need to change Dockerfile or docker-compose.yml to make sure files are overwritten when rebuilding?
I get the same error even after creating the database and a table in PostgreSQL and running
docker compose build
. Below is the output of
docker compose up
.
docker compose up
Attaching to db, django_app
db |
db | PostgreSQL Database directory appears to contain a database; Skipping initialization
db |
db | 2023-06-09 11:43:08.562 UTC [1] LOG: starting PostgreSQL 12.15 (Debian 12.15-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
db | 2023-06-09 11:43:08.563 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db | 2023-06-09 11:43:08.563 UTC [1] LOG: listening on IPv6 address "::", port 5432
db | 2023-06-09 11:43:08.564 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db | 2023-06-09 11:43:08.580 UTC [27] LOG: database system was shut down at 2023-06-09 11:32:17 UTC
db | 2023-06-09 11:43:08.587 UTC [1] LOG: database system is ready to accept connections
django_app | Creating Migrations...
django_app | Migrations for 'django_app':
django_app | django_app/migrations/0001_initial.py
django_app | - Create model User
django_app | ====================================
django_app | Starting Migrations...
django_app | Operations to perform:
django_app | Apply all migrations: admin, auth, contenttypes, django_app, sessions
django_app | Running migrations:
django_app | No migrations to apply.
django_app | ====================================
django_app | Starting Server...
django_app | Watching for file changes with StatReloader
django_app | Performing system checks...
django_app |
django_app | System check identified no issues (0 silenced).
django_app | June 09, 2023 - 11:43:10
django_app | Django version 3.2.5, using settings 'django_project.settings'
django_app | Starting development server at http://0.0.0.0:8000/
django_app | Quit the server with CONTROL-C.
django_app | Not Found: /
django_app | [09/Jun/2023 11:43:13] "GET / HTTP/1.1" 404 2171
1.) I used Dbeaver to have an interface for my postgres database. But I got connection error says FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
2.) The moment I run docker compose up I dont see output in terminal that is similar to the content of django.sh file.
I am using a windows with linux subsysmtem using ubuntu. I run the djangoproject in ubuntu 22.04 linux subsystem.
But your project tutorial works fine if I use the standard procedure or standalone django and postgre, without using Docker.
But if I use docker, I encountered the error I said earlier
Cool.
I tried this to learn a bit about docker. I don't think I understand how it is supposed to work.
When I first went through the steps I've got an error:
Which is pretty obvious, I forgot to import include, my issue is I don't know how to update the code in the container.
I would expect rebuilding should fix that, but it doesn't.
I have also tried to remove everything and retrace my steps.
line 2. Did you import the include?
That's exactly how I tried to fix that. I have that code in my project folder, but no matter what I do the container seems to be stuck with the old code.
Do I need to change Dockerfile or docker-compose.yml to make sure files are overwritten when rebuilding?
did you try docker compose up --build?
Yes, that's what I said would expect to update the container.
That's my luck. I always run into some weird bugs. I will have to try later on my other pc.
I'd suggest to try again from scratch and when you find the error you let me know here. good luck
Hi Francesco,
First of all, a huge thanks for for putting in so much effort in creating this comprehensive and easy to follow step-by-step tutorial.
I was able to successfully run
docker compose buildbut when I run
docker compose upI get this error
I ran
docker compose downchecked the logs for errors and I could not find any.
did you check the video on YouTube?
Not yet. I will do that some other day. Thank you.
no problem
Update:
I get the same error even after creating the database and a table in PostgreSQL and running
docker compose build. Below is the output of
docker compose up.
did you manage to solve it?
Not yet. If I try this once more and face any issues, I will update.
ok good luck
I have encountered some issues.
1.) I used Dbeaver to have an interface for my postgres database. But I got connection error says
FATAL: password authentication failed for user "postgres"FATAL: password authentication failed for user "postgres"
2.) The moment I run
docker compose upI dont see output in terminal that is similar to the content of django.sh file.I am using a windows with linux subsysmtem using ubuntu. I run the djangoproject in ubuntu 22.04 linux subsystem.
But your project tutorial works fine if I use the standard procedure or standalone django and postgre, without using Docker.
But if I use docker, I encountered the error I said earlier
hi. for point one, it really seems like a wrong password issue, beecause it's trying to authenticate.
Did you check the youtube video?
thank
you are welcome
Thank you very much for the post. It was very helpful.
you are welcome Ava
Nice 👍
Why not use a Django Rest Framework ModelviewSet instead?
With pagination too. 😁
Btw, you said you would use Python 3.10, not 3.7 😉
I just used this simple one.
you are partially correct, because I used Python 3.10 on my machine, that's the requirement just to run the django-admin CLI command
you odn't really need python 3.7 because you tun it inside a docker container.
I hope this was clear