我已在本地安装了postgresql,并希望将docker实例连接到本地。
docker run命令包括:
run:
IMAGE=$(IMAGE) CONFIG=$(config) docker-compose -f docker-compose.yml up -d
local:
@make build
@echo "\nCreate docker container.."
@make run config=$(config)
@echo "\n$(GREEN)Done.$(NO_COLOR)\n"
@echo "Try pallet at http://localhost:8080."
@echo "and flower at http://localhost:5555."
POSTGRES_HOST=192.168.0.142:5432
POSTGRES_PORT=5432
POSTGRES_CREDS=pallet:pallet
分别是docker和环境文件中的设置。
docker构建成功,但是出现以下错误:
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (psycopg2.OperationalError) FATAL: no pg_hba.conf entry for host "172.21.0.2", user "pallet", database "airflow", SSL on
FATAL: no pg_hba.conf entry for host "172.21.0.2", user "pallet", database "airflow", SSL off
我已经更改了配置文件:
# - Connection Settings -
listen_addresses = '0.0.0.0' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
#bonjour = off # advertise server via Bonjour
# (change requires restart)
#bonjour_name = '' # defaults to the computer name
# (change requires restart)
# - Security and Authentication -
#authentication_timeout = 1min # 1s-600s
ssl = true # (change requires restart)
#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
# (change requires restart)
#ssl_prefer_server_ciphers = on # (change requires restart)
#ssl_ecdh_curve = 'prime256v1' # (change requires restart)
ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' # (change requires restart)
ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' # (change requires restart)
#ssl_ca_file = '' # (change requires restart)
#ssl_crl_file = '' # (change requires restart)
#password_encryption = on
#db_user_namespace = off
#row_security = on
# GSSAPI using Kerberos
#krb_server_keyfile = ''
#krb_caseins_users = off
# - TCP Keepalives -
# see "man 7 tcp" for details
#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds;
# 0 selects the system default
#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds;
# 0 selects the system default
#tcp_keepalives_count = 0 # TCP_KEEPCNT;
# 0 selects the system default
行已添加:
#hostssl "airflow" "pallet" '*' md5
#hostnossl "airflow" "pallet" '*' md5
host all all '*' trust
是的,我没有注释,然后在文件/etc/postgresql/9.5/main/pg_hba.conf
中运行了它们中的每一个
答案 0 :(得分:1)
将以下行添加到pg_hba.conf
host all all all trust
或更具体些。
错误消息非常清楚地表明不允许使用主机IP。