If the django site is one docker image and the postgresql is another docker image, you would connect them together via docker-compose.yml (simply speaking).
Taking an example from Docker docs <https://docs.docker.com/samples/django/>, you need a Dockerfile (example file link here <https://github.com/docker/awesome-compose/blob/master/django/app/Dockerfile>) with the requirements.txt file available to Dockerfile to build a docker image. The compose.yaml or docker-compose.yml contains the docker build for the Django app, but at the same time, builds the sql (in this case, a postgresql) database and connects them both here: services: db: image: postgres volumes: - ./data/db:/var/lib/postgresql/data environment: - POSTGRES_DB=postgres - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" environment: - POSTGRES_NAME=postgres - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres depends_on: - db The structure would look like this: . ├── compose.yaml ├── app ├── Dockerfile ├── requirements.txt └── manage.py Then run `docker compose -f compose.yaml` or whatever the file name be if its not docker-compose.yaml or docker-compose.yml More detailed explanation can be found here: awesome-compose/official-documentation-samples/django at master · docker/awesome-compose (github.com) <https://github.com/docker/awesome-compose/tree/master/official-documentation-samples/django/> On Mon, 30 Sept 2024 at 23:43, Hernan Gustavo <hernang.w...@gmail.com> wrote: > Hi *Sreedhar.* > > Can you show us your docker files? Dockerfiles and .yml > > El lun, 30 sept 2024 a la(s) 10:00 a.m., Sreedhar p (psridhar...@gmail.com) > escribió: > >> Can any one explain how to connect django site with sql in docker >> containers >> I created two containers one for application and one for sql database in >> same network the database is exposed in port no 3307 application requests >> does not process by database then how to solve this? >> >> On Sat, Sep 28, 2024, 21:21 Abdul Qoyyuum Haji Abdul Kadir < >> abdul.qoyy...@gmail.com> wrote: >> >>> Can we not start a hello thread and spam everyone, please? Thank you. >>> >>> On Sat, 28 Sept 2024 at 23:50, Van Kamanga <vankaman...@gmail.com> >>> wrote: >>> >>>> Hi >>>> >>>> Le sam. 28 sept. 2024, 16:29, Shivansh Varshney < >>>> shivanshvarshne...@gmail.com> a écrit : >>>> >>>>> Hii >>>>> >>>>> On Saturday, September 28, 2024 at 1:12:35 AM UTC+5:30 Sreedhar p >>>>> wrote: >>>>> >>>>>> Hii >>>>>> >>>>>> On Sat, Sep 28, 2024, 00:32 <oladipo...@gmail.com> wrote: >>>>>> >>>>>>> hi >>>>>> >>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Django users" group. >>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>> send an email to django-users...@googlegroups.com. >>>>>>> >>>>>> To view this discussion on the web visit >>>>>>> https://groups.google.com/d/msgid/django-users/CA%2BARzD80pkTOKygrz8YogMFK1WfTpXGdimcPQ4jGXVe0D18GqQ%40mail.gmail.com >>>>>>> <https://groups.google.com/d/msgid/django-users/CA%2BARzD80pkTOKygrz8YogMFK1WfTpXGdimcPQ4jGXVe0D18GqQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>>> . >>>>>>> >>>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Django users" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to django-users+unsubscr...@googlegroups.com. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/django-users/42e4df1e-563b-4b37-9fb0-88bf0edfdd3bn%40googlegroups.com >>>>> <https://groups.google.com/d/msgid/django-users/42e4df1e-563b-4b37-9fb0-88bf0edfdd3bn%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Django users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to django-users+unsubscr...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-users/CA%2BGQzJNWSKruVFo3K1vsQf7eoe5MO8tF7HaAxs7V-1C%3D-_0NJA%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/django-users/CA%2BGQzJNWSKruVFo3K1vsQf7eoe5MO8tF7HaAxs7V-1C%3D-_0NJA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >>> >>> -- >>> Abdul Qoyyuum Bin Haji Abdul Kadir >>> Nickname: Q >>> More about me: https://buymeacoffee.com/qoyyuum >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django-users+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/CANVqoJ9_z%3D%3DMC_CfJ69ub0KU%3DR5a31ZPCx-SP-V7741a584Edg%40mail.gmail.com >>> <https://groups.google.com/d/msgid/django-users/CANVqoJ9_z%3D%3DMC_CfJ69ub0KU%3DR5a31ZPCx-SP-V7741a584Edg%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CADzXRbeqS%3DQhq%3D1t59EM4LQFGt2DLA5aHTiGpDTAmmTbU2aLKw%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CADzXRbeqS%3DQhq%3D1t59EM4LQFGt2DLA5aHTiGpDTAmmTbU2aLKw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAH6XLKgkpwniDiZpEakLLjOuYm0-TK%2B3Rr_Jy5fReFx6MHb0Tw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAH6XLKgkpwniDiZpEakLLjOuYm0-TK%2B3Rr_Jy5fReFx6MHb0Tw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- Abdul Qoyyuum Bin Haji Abdul Kadir Nickname: Q More about me: https://buymeacoffee.com/qoyyuum -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANVqoJ_nnnWppbYQ4DEhtds-SF_XvSXYRKZfQPMWxVKFaVEfPw%40mail.gmail.com.