How to link from docker-compose to Amazon RDS

你。 提交于 2019-12-06 02:04:48

问题


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


回答1:


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,
    }
}


来源:https://stackoverflow.com/questions/34833640/how-to-link-from-docker-compose-to-amazon-rds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!