我停靠现有的Django应用程序,但我正在努力初始化数据库和连接。我的alter table airlinetestcsv
SET SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde';
服务启动时使用以下配置,这对我来说是正确的:
db
此时,我希望单独的api容器能够连接,但我得到了
db:
build:
context: /Users/ben/Projects/project-falcon/project-falcon-containers
dockerfile: Dockerfile-db-local
environment:
POSTGRES_DB: falcon_db
POSTGRES_PASSWORD: falcon
POSTGRES_USER: falcon
ports:
- 5432:5432/tcp
restart: always
相关设置文件:
django.db.utils.OperationalError: FATAL: role "falcon" does not exist
内置于from .dev import *
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ['DB_NAME'],
'USER': os.environ['DB_USER'],
'PASSWORD': os.environ['DB_PASS'],
'HOST': os.environ['DB_SERVICE'],
'PORT': os.environ['DB_PORT']
}
}
并由此配置
api
基于the postgres
container的文档,我期望api:
build:
context: /Users/ben/Projects/falcon/falcon-backend
dockerfile: Dockerfile
depends_on:
- db
- redis
environment:
DB_NAME: falcon_db
DB_PASS: falcon
DB_PORT: '5432'
DB_SERVICE: db
DB_USER: falcon
ports:
- 8001:8001/tcp
volumes:
- /Users/ben/Projects/falcon/falcon-backend:/falcon:rw
变量创建Django期望连接为/的用户/数据库。但错误信息确实让我觉得它没有。所以基于文档和以下问题:
How to create User/Database in script for Docker Postgres
我尝试了指定要运行的特定POSTGRES_*
文件的旧方法
.sql
在#init.sql
CREATE USER falcon WITH PASSWORD 'falcon';
CREATE DATABASE falcon_db;
grant all privileges on database falcon_db to falcon;
ALTER USER falcon CREATEDB;
CREATE EXTENSION adminpack;
服务的Dockerfile
db
我能正确理解文件吗?我正确地解释了错误吗? VM上的unix用户是否有问题?任何帮助将不胜感激。