posts/docker-compose-django-postgres-nginx/ #31
Replies: 85 comments
-
Original author: Maxim Dunavicher @maximdunavicher Amazing blog, helped me a lot. |
Beta Was this translation helpful? Give feedback.
-
Original date: 2018-07-28T14:22:03Z You're welcome, glad I could help :) ! |
Beta Was this translation helpful? Give feedback.
-
Original author: Maxim Dunavicher @maximdunavicher Btw, do you work with pycharm? it seems I can't use the debug command because nginx crashes immidiately. I would probably owe you my sanity... |
Beta Was this translation helpful? Give feedback.
-
Original date: 2018-07-30T11:17:15Z So, for potential readers, here are some solutions: - add "nginx" as a dependency of "djangoapp" in docker-compose.yml (so pycharm also runs nginx when specifying service as "djangoapp") - bind port: 8000:8000 for the djangoapp service (you don't need nginx to debug) - in pycharm professional edition, you can leave blank the service part of a docker-compose configuration, and pycharm will run "docker-compose up -d", meaning nginx will also be started |
Beta Was this translation helpful? Give feedback.
-
Original author: Anon I am trying to use a Unix socket instead of a TCP/IP port for the communication between the Gunicorn server and NGINX. I have tried the above post, https://stackoverflow.com/q..., but to no avail. Do you know how to expose the Unix socket from the djangoapp container to the NGINX container? |
Beta Was this translation helpful? Give feedback.
-
Original date: 2018-08-01T19:33:29Z Since both djangoapp and nginx services need access to the socket, you need to create the socket into a named volume and bind it to both - if you followed this post you should know how to declare a new volume and bind it to djangoapp and nginx services :) Let say you want your socket to be located at /run/gunicorn.sock: |
Beta Was this translation helpful? Give feedback.
-
Original author: Anon Thanks for the help and blog :) |
Beta Was this translation helpful? Give feedback.
-
Original author: Ronaldo Mata @ronaldo_mata I have this problem: "could not translate host name "database1" to address: Name or service not known" can you help me? |
Beta Was this translation helpful? Give feedback.
-
Original date: 2018-08-14T18:41:52Z It may be because the database container was not ready before the djangoapp or nginx one. Just try to run your command again. The database will already be initialized in the named volume so it should start faster and be reachable from django/nginx. |
Beta Was this translation helpful? Give feedback.
-
Original author: Ronaldo Mata @ronaldo_mata Done! Thanks. This post is great! |
Beta Was this translation helpful? Give feedback.
-
Original author: Alexander Lebedev Thank you for the post! It was really helpful! Could you please explain why there is a 8000:80 port set up for nginx in `docker-compose` file. This set up didn't work out for me while I was deploying to AWS. I changed to 80:80 and it all worked. |
Beta Was this translation helpful? Give feedback.
-
Original date: 2018-08-28T13:24:07Z Ah! It's because I wrote this post for a development environment, not a production one! Indeed in production you must use 80:80. I'll add this as a note. Thanks for your comment :) |
Beta Was this translation helpful? Give feedback.
-
Original author: Rommel Hi! I got really confused on how to run this on aws without typing the port. I got an error when I change the port of nginx in docker-compose.yaml to 80:80
|
Beta Was this translation helpful? Give feedback.
-
Original date: 2018-09-20T18:23:23Z Hmmm? I suspect you have another program on your AWS listening to port 80. You can check that with a command like |
Beta Was this translation helpful? Give feedback.
-
Original author: Mihail Hi! When serving static files, more than 1 mb, nginx sends 403. on smaller files everything ok. how can i fix it? |
Beta Was this translation helpful? Give feedback.
-
Original author: Rishabh Kumar Hey i am facing the same issue can you please help me could not translate host name "database1" to address : name or service not known |
Beta Was this translation helpful? Give feedback.
-
Original date: 2020-02-18T17:59:03Z It often fails the first time because the database is not ready yet. I'd recommend trying to run the command again. Also make sure that you are running this command inside the container (docker-compose run). |
Beta Was this translation helpful? Give feedback.
-
Original author: Rishabh Kumar Hi i have tried this command lot of the time but everytime i get the same response even i am running in container sudo docker-compose run --rm djangoapp /bin/bash -c "cd businesss; ./manage.py migrate" |
Beta Was this translation helpful? Give feedback.
-
Original author: Rishabh Kumar Now i am getting this error |
Beta Was this translation helpful? Give feedback.
-
Original author: wanshousi thank you.谢谢! |
Beta Was this translation helpful? Give feedback.
-
Original date: 2020-03-16T18:02:40Z What is the purpose of a gunicorn.service file? |
Beta Was this translation helpful? Give feedback.
-
Original author: York Yer @Yorkyer This is a really amazing tutorial! I read it and do it until midnight, and when I finish it, I'm feel so happy! Thank you! |
Beta Was this translation helpful? Give feedback.
-
Original date: 2020-04-27T17:18:11Z Nice, good job! Thank you too! |
Beta Was this translation helpful? Give feedback.
-
Original author: Kipchirchir langat @kipchirchirlangat Hello pawamoy, for some reason, my page cannot display media files, and i have fully followed your tutorial,i am using django rest framework with react. I get an error that err connection refused, any workaround? |
Beta Was this translation helpful? Give feedback.
-
Original date: 2020-05-30T11:20:57Z Hello, unfortunately I cannot help you with only a vague "err connection refused" message ^^' I also never used React, and very little of DRF :/ Try to post a more detailed question on StackOverflow? |
Beta Was this translation helpful? Give feedback.
-
Thank you! Helped me a lot! |
Beta Was this translation helpful? Give feedback.
-
You're welcome @YakhyaevRasul, glad it helped! |
Beta Was this translation helpful? Give feedback.
-
Should be great to include |
Beta Was this translation helpful? Give feedback.
-
@xavirg I think it's out of scope for this tutorial. I don't want to fix this config option to an arbitrary value like 100M since it completely depends on the project you work on. Also the error message is pretty intuitive 🙂 Thanks for the suggestion! |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for this tutorial in order to get the static to load i had to change : |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Docker Compose with NginX, Django, Gunicorn and multiple Postgres databases - pawamoy's website
Findings, thoughts, tutorials, work. Pieces of my mind!
https://pawamoy.github.io/posts/docker-compose-django-postgres-nginx/
Beta Was this translation helpful? Give feedback.
All reactions