PostgreSQL docker:“无法绑定IPv6套接字:无法分配请求的地址” [英] PostgreSQL docker: "could not bind IPv6 socket: Cannot assign requested address"

查看:891
本文介绍了PostgreSQL docker:“无法绑定IPv6套接字:无法分配请求的地址”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑2:很长一段时间后,解决了!请参阅下面的答案。

编辑:很遗憾地说,问题在昨天和今天之间自行消失,而没有我做任何东西。很好的非确定性课程,可在此处学习...
额外的乐趣:错误日志中仍然出现无法绑定IPv6套接字错误,因此,这甚至可能根本不是问题。

I am sorry to say that the the problems went away "on their own" between yesterday and today, without me having done anything. Great non-deterministic lesson to learn here... Bonus fun: the "could not bind IPv6 socket" error still appears in the error logs, so this was probably not even the problem in the first place.

我以前使用的docker PGSQL映像有问题。直到昨天(--- D)毫无灵感地进行重建,在过去的5个月中,我已经成功使用了此构建。

I have a problem with a previously functioning docker PGSQL image. Until an uninspired rebuild yesterday ( :-D ), I've used this build successfully for the last 5+ months.

我的系统:


  • Ubuntu 17.04 64b

  • PGSQL 9.6.4

  • Docker版本17.11.0-ce,内部版本1caf76c

  • 我正在将主机端口5433映射到容器端口5432

  • Ubuntu 17.04 64b
  • PGSQL 9.6.4
  • Docker version 17.11.0-ce, build 1caf76c
  • I am mapping host port 5433 to container port 5432

问题(来自PGSQL日志的片段):

The problem (snippet from the PGSQL logs):


...

...

日志:无法绑定IPv6套接字:无法分配请求的地址

LOG: could not bind IPv6 socket: Cannot assign requested address

提示:另一个邮局主管已经在端口5432上运行了吗?如果没有,请等待几秒钟,然后重试。

HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

...

这是 ss 告诉我的(显然是在容器运行时):

This is what ss is telling me (when the container is running, obviously):

    $ docker exec -it db ss -atune
    Netid  State      Recv-Q Send-Q     Local Address:Port       Peer Address:Port 
    udp    ESTAB      0      0              127.0.0.1:45876         127.0.0.1:45876  uid:999 ino:147509 sk:00000001 <->
    tcp    LISTEN     0      128            127.0.0.1:5432                  *:*      uid:999 ino:147500 sk:00000002 <->

我已经清理了所有docker容器/映像,我已经重新安装了docker,没有任何帮助。谁可以使用容器中的5432端口?
为此,我是否正确阅读了以下内容,即PGSQL抱怨docker容器中已经使用了5432端口?

I've cleaned all docker containers / images, I've reinstalled docker, nothing helped. Who can possibly be using the 5432 port in the container? For that matter, am I reading this correctly, that PGSQL is complaining about the 5432 port being already used in the docker container?

即使您没有解决方案,有关如何进行调试的基本思路将对您大有帮助。

Even if you have no solution, a basic idea of how to proceed with debugging this would be a great help.

编辑:

postgres.docker文件

FROM postgres:9.6.4

ADD bin/postgres-setup.sh /docker-entrypoint-initdb.d/postgres-setup.sh

RUN chmod 755 /docker-entrypoint-initdb.d/postgres-setup.sh && \
    apt-get update && \
    apt-get install -y --no-install-recommends postgresql-plpython3-9.6 python3-pip postgresql-9.6-pldebugger && \
    pip3 install pyexcel pyexcel-xls pyexcel-xlsx pyexcel-xlsxw


推荐答案

经过很长一段时间,我们终于弄清楚了问题所在,在这里添加了说明,以防其他人使用。

After a long time, we finally figured out what was the problem -- adding explanation here, in case it helps others.

由于pgsql进行了监听

Since pgsql listens only to localhost by default, when it is running in the docker container, where we have the port mapping configuration, the external API was not able to connect to the pgsql server.

>解决方案是允许pgsql侦听所有IP地址:

The solution is to allow pgsql to listen to all IP addresses:


  1. 连接到db容器shell: $ docker exec -ti db bash

更改配置文件 / var / lib / postgresql / data / postgresql.conf 允许pgsql监听所有IP: listen_addresses ='*'

Change the configuration file /var/lib/postgresql/data/postgresql.conf to allow pgsql to listen to all IPs: listen_addresses = '*'

这篇关于PostgreSQL docker:“无法绑定IPv6套接字:无法分配请求的地址”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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