我的docker-compose.yml看起来像这样:
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"
如何将django容器链接到Amazon RDS,其中包含以下URL:example.blahblahblah.eu-west-1.rds.amazonaws.com:5432
解决方法
在这种情况下,您不必定义“链接”;数据库服务已经在运行,所以您需要做的就是配置您的django应用程序以连接到该主机.
我没有django的经验,但基于example in the docker-compose documentation,它看起来像;
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2','NAME': 'postgres','USER': 'postgres','HOST': 'example.blahblahblah.eu-west-1.rds.amazonaws.com','PORT': 5432,} }