Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
由于postgis端口问题,与docker容器的连接失败_Docker_Docker Compose_Postgis - Fatal编程技术网

由于postgis端口问题,与docker容器的连接失败

由于postgis端口问题,与docker容器的连接失败,docker,docker-compose,postgis,Docker,Docker Compose,Postgis,我的docker容器能够成功生成,但当我输入命令docker compose build时,返回以下错误: Starting docker_etl_1 ... Starting 1e5f56853e10_1e5f56853e10_1e5f56853e10_docker_postgis_1 ... Starting 1e5f56853e10_1e5f56853e10_1e5f56853e10_docker_postgis_1 Starting 1e5f56853e10_1e5f56853e10

我的docker容器能够成功生成,但当我输入命令
docker compose build
时,返回以下错误:

Starting docker_etl_1 ... 
Starting 1e5f56853e10_1e5f56853e10_1e5f56853e10_docker_postgis_1 ... 
Starting 1e5f56853e10_1e5f56853e10_1e5f56853e10_docker_postgis_1
Starting 1e5f56853e10_1e5f56853e10_1e5f56853e10_docker_postgis_1 ... error

ERROR: for 1e5f56853e10_1e5f56853e10_1e5f56853e10_docker_postgis_1  Cannot start service postgis: driver failed programming external connectivity on endpoint 1e5f56853e10_1e5f56853e10_1e5f56853e10_docker_postgis_1 (91464afbee8bf7212061797ec0f4c017a56cc3c30c9bdaf513127a6e6a4a5a52): Error starting userland prStarting docker_etl_1 ... done

ERROR: for postgis  Cannot start service postgis: driver failed programming external connectivity on endpoint 1e5f56853e10_1e5f56853e10_1e5f56853e10_docker_postgis_1 (91464afbee8bf7212061797ec0f4c017a56cc3c30c9bdaf513127a6e6a4a5a52): Error starting userland proxy: Bind for 0.0.0.0:5432 failed: port is already allocated
这是我的docker-compose.yaml

version: '2'
services:
  postgis:
    build: ./postgis
    volumes:
      - ../src/main/sql:/sql
    ports:
      - "5432:5432"

  etl:
    build: ./etl
    volumes:
      - ..:/national-voter-file
    entrypoint:
      - python3
      - /national-voter-file/load/loader.py
下面是Dockerfile:

FROM mdillon/postgis:9.5

ENV POSTGRES_DB VOTER

RUN  mkdir /sql
COPY ./dockerResources/z-init-db.sh /docker-entrypoint-initdb.d/

EXPOSE 5432
Docker ps-a
返回:

CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                          PORTS               NAMES
da74ad97b95c        docker_postgis      "docker-entrypoint..."   About a minute ago   Created                                             docker_postgis_1
5872c6e55fe2        docker_etl          "python3 /national..."   About a minute ago   Exited (2) About a minute ago                       docker_etl_1
但是,当我尝试
rm$(docker ps-qa)
时,我得到以下错误:

rm: da74ad97b95c: No such file or directory
rm: 5872c6e55fe2: No such file or directory

我不相信我运行了另一个容器,因此我被消息
绑定0.0.0.0:5432失败:端口已经分配了

是否可能您之前运行了相同的docker compose,它可能失败或至少未能清理服务?
尝试运行
docker ps-a
检查是否存在任何停止的容器。可能是停止的集装箱占据了港口。如果是这样,只需使用docker rm$(docker ps-qa)

将其清除即可。您只需检查是否有任何内容绑定到该端口-
lsof-i4 | grep 5432
,等等。@OliverCharlesworth该命令不会返回任何内容。应该吗?听起来您的系统上运行的某些东西已经占用了端口5432。您的主机上是否已经运行了postgres实例?@programmerq这就是问题所在。谢谢我已经用这些命令的输出更新了我的问题。为什么remove命令找不到正确的文件?