I'm trying to deploy my Django app on docker ,but when i run the container it shows:
psycopg2.OperationalError: FATAL: database "NUTEK" does not exist
my docker-compose.yml file:
version: '2.1'
services:
web:
restart: always
build: ./web
expose:
- "8000"
links:
- postgres:postgres
- redis:redis
volumes:
- /usr/src/app
- /usr/src/app/static
nginx:
restart: always
build: ./nginx/
ports:
- "80:80"
volumes:
- /www/static
links:
- web:web
postgres:
restart: always
image: postgres:10.6
ports:
- "5432:5432"
redis:
restart: always
image: redis:latest
ports:
- "6379:6379"
my Dockerfile:
FROM python:3.6.6-onbuild
CMD ["python", "manage.py","run server"]
the settings.py file of my Django app:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'NUTEK',
'USER': 'postgres',
'PASSWORD': 'root',
'HOST': 'postgres',
'PORT': '5432',
}
}
my .env file:
SECRET_KEY='secret'
DB_NAME=NUTEK
DB_USER=postgres
DB_PASS=root
DB_SERVICE=postgres
DB_PORT=5432
i've searched on issues on the github repository of docker-libraries/postgres and stackoverflow and i found that i should create the database :
docker run -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=root -e POSTGRES_DB=NUTEK postgres
but that didn't help also ,hope someone can help .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.