docker-compose psql无法连接到服务器

阿什什·帕达卡纳亚(Ashish Padakannaya)

我查看了瓶装水的github MD文件以使用docker来使用它,而我遇到了有关postgresql的问题

如果我运行docker-compose run --rm postgres psql我得到错误

/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

这是我的docker-compose.yml文件中的postgres和psql的配置

postgres:
   build: ./tmp
   dockerfile: Dockerfile.postgres
   hostname: postgres
   ports:
     - '45432:5432' 

psql:
  image: postgres:9.4
  links:
    - postgres
  command: 'sh -c ''exec psql -h "localhost" -p "5432" -U postgres'''

这是我的pg_hba.conf文件

local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

我已经在这里待了几天了,任何帮助都将不胜感激!谢谢

00500005

这是docker compose的文献记载很少的功能,因为它也使我措手不及。它在文档中看看是否可以找到它。

链接两个容器时,将使用虚拟主机名链接它们。如果检查/etc/hosts您的psql联系人,则会发现别名行,postgres {foldername}_postgres_1其中docker {foldername}-compose项目的父文件夹名称是。

要使用链接的容器,请使用主机名postgres

例如:

psql:
  image: postgres:9.4
  links:
    - postgres
  command: 'sh -c ''exec psql -h "postgres" -p "5432" -U postgres'''

您可以配置您的代码库以使用它。如果要在链接容器之外运行代码,只需修改主机/etc/hosts文件以指向所需的服务即可。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

docker-compose中的“无法连接到本地MySQL服务器”

来自分类Dev

无法在docker-compose(php和MariaDB)中连接到数据库服务器

来自分类Dev

docker-compose中的“无法连接到本地MySQL服务器”

来自分类Dev

由Docker-Compose启动的Mongo-Express导致错误[MongoError]:首次连接时无法连接到服务器[mongo:27017]

来自分类Dev

为什么我无法连接到此docker compose服务?

来自分类Dev

Docker-Compose无法连接到MySQL

来自分类Dev

Docker Compose:无法连接到Postgres

来自分类Dev

grpc服务器无法在docker-compose中工作

来自分类Dev

Docker-compose服务器无法访问

来自分类Dev

docker-compose无法连接到docker守护进程?

来自分类Dev

docker compose 无法构建

来自分类Dev

无法连接到从docker-compose运行的MongoDB

来自分类Dev

docker-compose无法连接到外部网络

来自分类Dev

.net核心无法连接到Postgres(Docker Compose)

来自分类Dev

无法连接到从docker-compose运行的MongoDB

来自分类Dev

无法连接到由 docker compose 启动的 .net 容器

来自分类Dev

docker-compose:无法连接到 memcached 容器

来自分类Dev

如何使用Docker Compose连接到Elasticsearch

来自分类Dev

使用Docker Compose运行解析服务器

来自分类Dev

使用Docker Compose时Discord机器人无法联系Discord服务器

来自分类Dev

Django应用程序服务器挂起/无法在Docker Compose中启动

来自分类Dev

Docker:使用 docker run 而不是 docker-compose up 时无法连接到 Redis

来自分类Dev

无法启动docker-compose

来自分类Dev

无法在OSX上使用Docker连接到X服务器

来自分类Dev

无法通过Airflow DAG连接到Docker Postgres服务器

来自分类Dev

R Docker:无法通过套接字连接到本地MySQL服务器

来自分类Dev

Docker容器无法连接到远程服务器上的SQL Server

来自分类Dev

Docker 容器无法连接到在本地主机上运行的服务器

来自分类Dev

HttpException: -404 运行 Docker 时无法连接到 mac 上的远程服务器

Related 相关文章

  1. 1

    docker-compose中的“无法连接到本地MySQL服务器”

  2. 2

    无法在docker-compose(php和MariaDB)中连接到数据库服务器

  3. 3

    docker-compose中的“无法连接到本地MySQL服务器”

  4. 4

    由Docker-Compose启动的Mongo-Express导致错误[MongoError]:首次连接时无法连接到服务器[mongo:27017]

  5. 5

    为什么我无法连接到此docker compose服务?

  6. 6

    Docker-Compose无法连接到MySQL

  7. 7

    Docker Compose:无法连接到Postgres

  8. 8

    grpc服务器无法在docker-compose中工作

  9. 9

    Docker-compose服务器无法访问

  10. 10

    docker-compose无法连接到docker守护进程?

  11. 11

    docker compose 无法构建

  12. 12

    无法连接到从docker-compose运行的MongoDB

  13. 13

    docker-compose无法连接到外部网络

  14. 14

    .net核心无法连接到Postgres(Docker Compose)

  15. 15

    无法连接到从docker-compose运行的MongoDB

  16. 16

    无法连接到由 docker compose 启动的 .net 容器

  17. 17

    docker-compose:无法连接到 memcached 容器

  18. 18

    如何使用Docker Compose连接到Elasticsearch

  19. 19

    使用Docker Compose运行解析服务器

  20. 20

    使用Docker Compose时Discord机器人无法联系Discord服务器

  21. 21

    Django应用程序服务器挂起/无法在Docker Compose中启动

  22. 22

    Docker:使用 docker run 而不是 docker-compose up 时无法连接到 Redis

  23. 23

    无法启动docker-compose

  24. 24

    无法在OSX上使用Docker连接到X服务器

  25. 25

    无法通过Airflow DAG连接到Docker Postgres服务器

  26. 26

    R Docker:无法通过套接字连接到本地MySQL服务器

  27. 27

    Docker容器无法连接到远程服务器上的SQL Server

  28. 28

    Docker 容器无法连接到在本地主机上运行的服务器

  29. 29

    HttpException: -404 运行 Docker 时无法连接到 mac 上的远程服务器

热门标签

归档