Docker Compose | How to configure PostgreSQL or MySQL database with Python Django

preview_player
Показать описание
In this Docker compose tutorial we start a Django application with Docker Compose and run it in a container. I will then show you how to configure a volume to build a mirrored folder from your computer and the container. This way you can develop on your computer but host the application in a container. Next up we configure first a PostgreSQL database and attach it to Django then build a bassline configuration for MySQL for a Django application. This is a docker compose tutorial for beginners. Take your first steps with Docker containers.

Code Repository:

🐱‍🏍Would you like to SUPPORT US FURTHER so that we can make even more great content - Please consider joining our members community.

👍SUBSCRIBE to get more free tutorials, courses and code snippets!
Комментарии
Автор

Zander, can you make a video with Django API + React Frontend Docker Package/Deployment? That would be a great addition to this series!!

akhillshetty
Автор

Awesome tutorial, thank you for all the good information

sotak
Автор

Thank you very much for this tutorial. You are a very good teacher.

edecilcorrea
Автор

Please teach us how to do *Docker + Django + React/Vue* much love!!

SoloPython
Автор

What about production? Do you have the real data stored on the machine, where the app is running? In this case in ./data/db?

naheliegend
Автор

Always releasing new interesting videos

benjaminagyekum
Автор

Where does the /var/lib/PostgreSQL/data come from?

RishiSaikia
Автор

Excellent,
But I am getting some error which can't be resolved by me.
Can you help me on that....

could not translate host name "db" to address: Temporary failure in name resolution

kaushalkhokhar
Автор

For those who are getting error: could not translate host name "db" to address: temporary failure in name resolution
You should consider adding the addiotional configs to your docker-compose file:
db:
image: postgres
ports:
- 5432:5432
volumes:
-
- pgconf:/etc/postgresql
- pglog:/var/log/postgresql
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
container_name: postgres_db
volumes:
pgdata:
driver: local
pgconf:
driver: local
pglog:
driver: local

devjeff
Автор

It is supposed to run both ways with or without docker.
Right?

apurvashirbhate
Автор

Getting an error as below:
docker endpoint for "default" not found
Please help.

Arjungtk
Автор

Is there a way to connect these hosted DBs on Docker with MySql Workbench or PG Admin installed on Host PC for monitoring purposes?

ayeshrodrigo
Автор

Why do you need to create another container for every service?

sergiaguilar
Автор

Is there a way to do the database migration that does not involve doing it manually via bash every time?

shivan
Автор

Hi, anyone with this error ? : raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django-container2 | Error loading psycopg2 module: No module named 'psycopg2'.
(UPDATE Fix) I had to delete my previous app image and create it again so it could install the psycopg2-binary package.

phaniophrero
Автор

Those who face pg_config executable not found. add below line inside Dockerfile
RUN pip install --upgrade pip
RUN pip3 install -r requirements.txt

sabarinathjv
Автор

i dont have 'data' directoty((

Kos