DEV Community

Cover image for Dockerize a Django, React, and Postgres application with docker and docker-compose | by Anjal Bam

Dockerize a Django, React, and Postgres application with docker and docker-compose | by Anjal Bam

AnjalBam on September 10, 2022

Introduction In the battlefield of modern web development, Django and React are both very great warriors that have been fighting battles...
Collapse
 
akhilnasim1123 profile image
Akhil Nasim • Edited

getting error 'docker-compose build'

docker-compose : The term 'docker-compose' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a

path was included, verify that the path is correct and try again.

Collapse
 
anjalbam profile image
AnjalBam

It seems like you've installed docker desktop. The latest version of docker compose has changed their command from 'docker-compose' to 'docker compose'.

So maybe you can try "docker compose build" instead.

Collapse
 
mayhrem profile image
Rene Francisco Cruz González

I really appreciate your post, It was very helpful and the good documentation was also good. Thanks for this contribution!

Collapse
 
anjalbam profile image
AnjalBam

I am glad it helped. Happy coding!

Collapse
 
johannquispe profile image
JohannQuispe

gracias mano, esto como funcionaria en produccion! perdona mi ignorancia

Collapse
 
jliucoder profile image
jLiucoder

Is it possible that we can have a toturial talking about how to use the pgadmin4 and connect with the the database, I have been trying different solutions but couldn't get it working, thanks so much for this!

Collapse
 
jliucoder profile image
jLiucoder

when i try to migrate the database it just shows me "could not translate host name "db" to address: nodename nor servname provided, or not known", could you tell me the possible solutions to fix this? Thanks so much!

Collapse
 
anjalbam profile image
AnjalBam

This is because you tried migrating from the normal shell, instead you should try updating it inside the docker container, you can do it with command "docker compose exec backend python manage.py migrate/makemigrations".

Thread Thread
 
jliucoder profile image
jLiucoder

Thanks so much for the help! If i am changing the dababase from postgres to mySQL, all i need to do it changing the database in the settings file right?

Thanks again, you def deserve more views and likes,

Thread Thread
 
anjalbam profile image
AnjalBam

Yes... you must write separate configurations for the MySQL Database server. But in django application only settings file changing is sufficient.

Glad to help! I really appreciate you saying those kind words.

Collapse
 
akhilnasim1123 profile image
Akhil Nasim

i have 5000 port for express route to call api to backend. and i have 8001 port for chatgpt integration. running code of 8001 is 'python app.py'. how can i add these two engine into docker with my frontend(3000) and backend(8000)

Collapse
 
johannquispe profile image
JohannQuispe

Muchisimas gracias me fue de mucha ayuda, pero disculpen mi ignorancia,!
como puedo llevar esto a produccion?!

Collapse
 
canis_lupus profile image
ABDELALI AIT TALB • Edited

That was good enough but I would like to point to know about about creating migrations to postgres db ? how that procces will be mad so ?