Contact docker-compose for Amazon RDS

My docker-compose.yml looks something like this:

django:
  build: .
  user: django
  links:
    # LINK TO AMAZON RDS?
  command: /gunicorn.sh
  env_file: config/settings/.env

nginx:
  build: ./compose/nginx
  links:
    - django
  ports:
    - "0.0.0.0:80:80"

How to associate a django container with Amazon RDS that has a url: example.blahblahblah.eu-west-1.rds.amazonaws.com:5432

+5
source share
1 answer

In this case, you do not need to define a “link”; the database service is already running, so all you have to do is configure your django application to connect to this host.

I have no experience with django, but based on the example in the docker documentation documentation , it will look something like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'postgres',
        'USER': 'postgres',
        'HOST': 'example.blahblahblah.eu-west-1.rds.amazonaws.com',
        'PORT': 5432,
    }
}
+9
source

All Articles