Hey everyone i am trying to connect my postgres database install in ubuntu 20.04 to the docker container, which will be outside of the container. I am working on django project.
I am able to create the postgres database inside the docker container and connect my django project to that database, but i want is to connect localdatabase to the django project which is running in docker container
Here is my docker-compose.yml file
version: '3.3'
services:
# Description (For the postgres databse)
kapediadb:
image: postgres
restart: always
container_name: kapediadb
# For accessing env data
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
# Description (For django applications)
kapedia:
restart: always
container_name: kapedia
command:
- /bin/bash
- -c
- |
python manage.py makemigrations accounts
python manage.py makemigrations posts
python manage.py makemigrations quiz
python manage.py migrate
gunicorn kapedia.wsgi:application --bind 0.0.0.0:8000
image: kapedia
# Description (define your dockerfile location here)
build: .
volumes:
- .:/kapedia
ports:
- "8000:8000"
depends_on:
- kapediadb
env_file:
- .env
# Description (For volumes)
volumes:
static: