使用localhost将docker-gramex容器中的 pandas 连接到主机上运行的数据库 [英] connect pandas in docker-gramex container, to database running on host machine using localhost

查看:89
本文介绍了使用localhost将docker-gramex容器中的 pandas 连接到主机上运行的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装 docker-gramex 后将应用程序连接到运行在数据库服务器上的

主机连接URL失败:'postgresql:// db_user:db_passwd @ localhost:5432 / db_name'
抛出 psycopg2.OperationalError可能无法连接到服务器:连接被拒绝
即使在博客文章

after installing docker-gramex connecting app to database server running on host machine fails for connection URL: 'postgresql://db_user:db_passwd@localhost:5432/db_name' throws psycopg2.OperationalError could not connect to server: Connection refused Error persist even after making changes given in blog-post

推荐答案

在带有ubuntu的AWS-EC2,使用cmd启动gramex:

docker run --network = host \
--name my-instance \
-d -i -t -p 9998:9998 \
-v $ {pwd): $ {pwd) -w $ {pwd) \
gramener / gramex

On AWS-EC2 with ubuntu, starting gramex using cmd: docker run --network=host \ --name my-instance \ -d -i -t -p 9998:9998 \ -v "$(pwd)":"$(pwd)" -w "$(pwd)" \ gramener/gramex

它允许熊猫连接到在主机上运行的postgresql服务器h连接URL:'postgresql:// db_user:db_passwd @ localhost:5432 / db_name'
参数:-network = host 使其起作用。

it allows pandas to connect to postgresql server running on the host machine with the connection URL: 'postgresql://db_user:db_passwd@localhost:5432/db_name' param: --network=host makes it work.

这篇关于使用localhost将docker-gramex容器中的 pandas 连接到主机上运行的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆