मेरे पास वर्तमान में डॉकर-कंपोज़ के साथ बनाई गई एक प्रणाली है, यह एक Django एप्लिकेशन बनाता है।django के साथ डॉकर-रचना पता करने के लिए होस्ट नाम "डीबी" का अनुवाद नहीं कर सका: नाम या सेवा ज्ञात नहीं है
अब तक मैंने अपने परीक्षण निर्माण में एक कंटेनर (postgresql) के अंदर डेटाबेस का उपयोग किया है। अब मैंने एएसडब्ल्यू में इस कंटेनर से आरडीएस इंस्टेंस में डेटाबेस बदल दिया है।
Pg_dump का उपयोग करके मैंने आरडीएस के अंदर डेटाबेस को फिर से बनाया है और settings.py बदल दिया है, सब कुछ सामान्य रूप से सामान्य था। मैंने बिना किसी समस्या के अपने वेबपैप के अंदर डेटाबेस से डेटा का उपयोग किया है।
सबकुछ तब तक ठीक था जब तक मुझे माइग्रेशन करना पड़ा।
django.db.utils.OperationalError: could not translate host name "db" to address: Name or service not known
मेरे डोकर-compose.yml फ़ाइल परिवर्तन से पहले:
version: '2'
services:
db:
image: postgres:9.5
restart: always
environment:
POSTGRES_USER: testing
POSTGRES_PASSWORD: tests
POSTGRES_DB: test
volumes:
- /dbdata:/var/lib/postgresql/data
django:
build: ./django
command: gunicorn contactto.wsgi:application -b 0.0.0.0:8000
restart: always
volumes:
- ./django:/usr/src/app
- ./django/static:/usr/src/app/contactto/static
ports:
- "8000:8000"
depends_on:
- db
अब परिवर्तन के बाद:
version: '2'
services:
django:
build: ./django
command: gunicorn contactto.wsgi:application -b 0.0.0.0:8000
restart: always
volumes:
- ./django:/usr/src/app
- ./django/static:/usr/src/app/contactto/static
ports:
- "8000:8000"
और डेटाबेस कंटेनर बिना Django कंटेनर मुझे यह संदेश देता है settings.py से डेटाबेस। से पहले:
DATABASES = {
'default': {
'ENGINE': 'tenant_schemas.postgresql_backend',
'NAME': 'testing',
'USER': 'test',
'PASSWORD': 'test',
'HOST': 'db',
'PORT': '5432',
}
}
के बाद:
DATABASES = {
'default': {
'ENGINE': 'tenant_schemas.postgresql_backend',
'NAME': 'testing',
'USER': 'test',
'PASSWORD': 'test',
'HOST': 'xxx.rds.amazonaws.com',
'PORT': '5432',
}
}
अजीब बात है, मैं अपने ऐप के अंदर एडब्ल्यूएस डेटाबेस का उपयोग कर सकते हैं ... मैं उपयोगकर्ताओं को बनाने और डेटाबेस के अंदर बातें करते हैं और परिवर्तन दिखाई दे सकता है । अब सीएलआई में मैं संदेश के बिना manage.py खोल का भी उपयोग नहीं कर सकता।
मैं पूरी तरह से खो गया हूं।