Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link from docker-compose to 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 do I link the django container to the Amazon RDS, which has an url like: example.blahblahblah.eu-west-1.rds.amazonaws.com:5432

like image 584
2083 Avatar asked Jan 17 '16 00:01

2083


People also ask

Can I run Docker compose in AWS?

It is now even easier for a developer to take a containerized microservices-based application from their workstation and deploy it straight to the AWS Cloud. Developers can now run docker compose up and deploy their existing Docker Compose files straight to Amazon ECS, as previously shown here.


1 Answers

In that case, you don't have to define a "link"; the database service is already running, so all you need to do, is configure your django app to connect to that host.

I don't have experience with django, but based on the example in the docker-compose documentation, it would look something like;

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'postgres',
        'USER': 'postgres',
        'HOST': 'example.blahblahblah.eu-west-1.rds.amazonaws.com',
        'PORT': 5432,
    }
}
like image 146
thaJeztah Avatar answered Sep 22 '22 19:09

thaJeztah