本地 Postgres 应用程序在端口 5432 上运行,但映射到该端口的 Docker Compose 服务运行时没有错误?

2024-03-30

我在 MacOS 上,Postgres 应用程序在默认端口 5432 上运行:

I ran docker-compose up对于以下docker-compose.yml:

version: "3.3"
services:
  postgresql:
    image: postgres:10.3-alpine
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_USER=admin
      - POSTGRES_PASSWORD=admin

  redis:
    image: redis:4.0.9-alpine
    ports:
      - "6379:6379"

据我了解https://docs.docker.com/compose/compose-file/#ports https://docs.docker.com/compose/compose-file/#ports,这会将主机上的端口 5432 映射到运行该容器的容器上的端口 5432postgresql服务。

由于该端口已在使用中,因此我运行时会出现错误docker-compose up。但命令运行正常:

Kurts-MacBook-Pro-2:lucy-web kurtpeek$ docker-compose up
Creating network "lucy-web_default" with the default driver
Pulling postgresql (postgres:10.3-alpine)...
10.3-alpine: Pulling from library/postgres
ff3a5c916c92: Pull complete
a503b44e1ce0: Pull complete
211706713093: Pull complete
ea28caf317dd: Pull complete
a9b37749335b: Pull complete
f7e94ebc5400: Pull complete
77dd3a51253d: Pull complete
633a37734b12: Pull complete
872e6b940bbb: Pull complete
Digest: sha256:904fdb16d13c78577c26710b31c46a9e5c66db54099bc46a64e7ecf1d9346a63
Status: Downloaded newer image for postgres:10.3-alpine
Pulling redis (redis:4.0.9-alpine)...
4.0.9-alpine: Pulling from library/redis
ff3a5c916c92: Already exists
aae70a2e6027: Pull complete
87c655da471c: Pull complete
7f8fb829cc48: Pull complete
c72e0cff027d: Pull complete
276d6b52cd5b: Pull complete
Digest: sha256:8782054ba81c3b8b969dae4822263a97fc241a06f8f1fe1acacd7c077ec60831
Status: Downloaded newer image for redis:4.0.9-alpine
Creating lucy-web_redis_1      ... done
Creating lucy-web_postgresql_1 ... done
Attaching to lucy-web_redis_1, lucy-web_postgresql_1
redis_1       | 1:C 30 Apr 20:55:17.407 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1       | 1:C 30 Apr 20:55:17.407 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1       | 1:C 30 Apr 20:55:17.407 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1       | 1:M 30 Apr 20:55:17.408 * Running mode=standalone, port=6379.
redis_1       | 1:M 30 Apr 20:55:17.408 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1       | 1:M 30 Apr 20:55:17.408 # Server initialized
redis_1       | 1:M 30 Apr 20:55:17.408 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1       | 1:M 30 Apr 20:55:17.408 * Ready to accept connections
postgresql_1  | The files belonging to this database system will be owned by user "postgres".
postgresql_1  | This user must also own the server process.
postgresql_1  | 
postgresql_1  | The database cluster will be initialized with locale "en_US.utf8".
postgresql_1  | The default database encoding has accordingly been set to "UTF8".
postgresql_1  | The default text search configuration will be set to "english".
postgresql_1  | 
postgresql_1  | Data page checksums are disabled.
postgresql_1  | 
postgresql_1  | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgresql_1  | creating subdirectories ... ok
postgresql_1  | selecting default max_connections ... 100
postgresql_1  | selecting default shared_buffers ... 128MB
postgresql_1  | selecting dynamic shared memory implementation ... posix
postgresql_1  | creating configuration files ... ok
postgresql_1  | running bootstrap script ... ok
postgresql_1  | performing post-bootstrap initialization ... sh: locale: not found
postgresql_1  | 2018-04-30 20:55:17.689 UTC [29] WARNING:  no usable system locales were found
postgresql_1  | ok
postgresql_1  | syncing data to disk ... ok
postgresql_1  | 
postgresql_1  | Success. You can now start the database server using:
postgresql_1  | 
postgresql_1  |     pg_ctl -D /var/lib/postgresql/data -l logfile start
postgresql_1  | 
postgresql_1  | 
postgresql_1  | WARNING: enabling "trust" authentication for local connections
postgresql_1  | You can change this by editing pg_hba.conf or using the option -A, or
postgresql_1  | --auth-local and --auth-host, the next time you run initdb.
postgresql_1  | waiting for server to start....2018-04-30 20:55:18.156 UTC [34] LOG:  listening on IPv4 address "127.0.0.1", port 5432
postgresql_1  | 2018-04-30 20:55:18.156 UTC [34] LOG:  could not bind IPv6 address "::1": Address not available
postgresql_1  | 2018-04-30 20:55:18.156 UTC [34] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
postgresql_1  | 2018-04-30 20:55:18.159 UTC [34] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgresql_1  | 2018-04-30 20:55:18.171 UTC [35] LOG:  database system was shut down at 2018-04-30 20:55:17 UTC
postgresql_1  | 2018-04-30 20:55:18.175 UTC [34] LOG:  database system is ready to accept connections
postgresql_1  |  done
postgresql_1  | server started
postgresql_1  | CREATE DATABASE
postgresql_1  | 
postgresql_1  | CREATE ROLE
postgresql_1  | 
postgresql_1  | 
postgresql_1  | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
postgresql_1  | 
postgresql_1  | waiting for server to shut down....2018-04-30 20:55:18.538 UTC [34] LOG:  received fast shutdown request
postgresql_1  | 2018-04-30 20:55:18.540 UTC [34] LOG:  aborting any active transactions
postgresql_1  | 2018-04-30 20:55:18.541 UTC [34] LOG:  worker process: logical replication launcher (PID 41) exited with exit code 1
postgresql_1  | 2018-04-30 20:55:18.541 UTC [36] LOG:  shutting down
postgresql_1  | 2018-04-30 20:55:18.552 UTC [34] LOG:  database system is shut down
postgresql_1  |  done
postgresql_1  | server stopped
postgresql_1  | 
postgresql_1  | PostgreSQL init process complete; ready for start up.
postgresql_1  | 
postgresql_1  | 2018-04-30 20:55:18.643 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgresql_1  | 2018-04-30 20:55:18.643 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgresql_1  | 2018-04-30 20:55:18.646 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgresql_1  | 2018-04-30 20:55:18.656 UTC [47] LOG:  database system was shut down at 2018-04-30 20:55:18 UTC
postgresql_1  | 2018-04-30 20:55:18.659 UTC [1] LOG:  database system is ready to accept connections

为什么我没有收到错误?现在,哪个数据库实际上应该监听我本地计算机的 5432 端口,是 Postgres 应用程序还是 Docker 容器中的数据库?


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

本地 Postgres 应用程序在端口 5432 上运行,但映射到该端口的 Docker Compose 服务运行时没有错误? 的相关文章

随机推荐

  • 如何使 JAWS 等屏幕阅读器可以访问“正在加载”图标?

    所以 HTML 代码是这样的 div style display none img src PT LOADING gif alt Processing please wait title div 即使提供了 ALT 文本 在更改样式以显示图
  • 函数 while 循环中的 return 是如何处理的?

    我有一个函数 该函数内部有一个 while 循环 当我尝试使用 IF 语句在 while 循环内设置非局部变量 然后退出整个函数时 突然该变量不再设置 function EXAMPLE cat test txt while read LIN
  • insertRow 与appendChild

    向表中添加行时首选哪种方法 var tr tbl insertRow 1 or var tr document createElement tr tbl appendChild tr insertRow会好得多 这是支持的 http www
  • 为什么此 GeoTool 片段不生成可查看的 shapefile?

    我正在创建一个简单的程序 它从 csv 文件读取值并根据这些值创建 shp 文件 这是一个轻微的修改这个例子 http docs geotools org latest tutorials feature csv2shp html 形状文件
  • JUL 适配器不适用于 Jersey

    我正在尝试使用七月适配器将 Java Util Logging 委托给 Log4j2 更准确地说 任何使用 JUL 生成日志的第三方库都应该委托给 Log4j2 作为一个简单的练习 我创建了一个使用库的独立应用程序 我创建这个库是为了测试目
  • Steam API 所有游戏

    我一直在阅读论坛并尝试 Steam API 我正在寻找提供所有 Steam 游戏的 API 我发现提供所有 SteamApp 的 API 以及提供应用程序信息的 Steam 商店 API 我正在寻找类型 游戏 但为此 我需要为每个 Stea
  • 如何在两个微服务之间共享 REST 服务实体?

    我使用 java 创建了两个微服务 我需要从服务 A 到服务 B 进行 REST api 调用 发送的数据将采用 JSON 格式 使用 jax rs 我需要在这两个服务中创建实体类 由于两个项目中的实体类相同 我可以吗 创建一个通用 jar
  • ES 2017:异步函数 vs AsyncFunction(object) vs 异步函数表达式

    我刚刚读到async functions并遇到了 ES2017 的一些类似功能 它造成了很多混乱 我只想问 有什么区别async function AsyncFunction 用于创建异步函数 和异步函数表达式 我认为这只是另一个异步函数
  • Scrapy 遭遇 DEBUG:爬行(400)

    我正在尝试使用 Scrapy 抓取页面 https zhuanlan zhihu com wangzhenotes 我运行这个命令 scrapy shell https zhuanlan zhihu com wangzhenotes and
  • python中的{}和[]有什么区别?

    有什么区别columnNames and columnNames 在Python中 我怎样才能迭代每一个 使用 for value in columnNames OR for idx o val o in enumerate columnN
  • 具有多个类约束的 Haskell 类型签名

    我怎样才能有多个类约束 所以如果A is an Eq and B is a Num 我可以说 f Eq a gt a gt b or f Num b gt a gt b 那么 我怎样才能拥有Eq a gt and Num b gt 同时 f
  • 如何自定义jquery滑块范围的颜色?

    使用 jquery 滑块时 我想将所选范围的默认颜色从灰色更改为蓝色 document ready function var slider slider slider range min min 0 max 100 change funct
  • 如何使用Lucene实现拼音搜索?

    我想使用 Lucene 6 1 0 Soundex 或任何适合葡萄牙语的算法来实现语音搜索 我在互联网上发现了许多不完整的示例 教如何实现自定义分词器 分析器 但似乎这些示例上使用的抽象类在 6 1 0 版本中并不相同 谁能指出我在哪里可以
  • 一元运算与赋值融合

    以下代码中的结果值得怀疑 public static void main String args int i 2 i i 2 i System out println i 本来期待着8作为输出 因为 i 2 应该update我 但它的行为并
  • 重写 XMLHttpRequest.open()

    我怎样才能覆盖XMLHttpRequest open 方法然后捕获并改变它的参数 我已经尝试过代理方法 但它不起作用 尽管删除了打开覆盖XMLHttpRequest 被称为 function var proxied window XMLHt
  • 帮助设置 Ruby on Rails 和 MySQL - 提供奖励

    我迫切需要任何慈善红宝石 Rails 专家的帮助 我真的很想学习RoR 但我无处可去 因为每次我到达需要连接数据库的阶段时 都会出现一些问题 这就是我现在要做的事情 Mac OSX 10 6 6 红宝石 1 9 2 导轨 3 0 5 MyS
  • WCF DataService 不支持预检选项请求?

    我想使用基于 ajax 的组件 KendoUI 来读取 修改 WCF DataServices 实现的 OData 端点上的实体 首先 服务实现相当简单 public class MyFooService DataService
  • 如何在 Windows 命令行中用不同的颜色进行回显

    我知道color bf命令设置整个命令行窗口的颜色 但我想以不同的颜色打印一行 我想用不同的颜色打印一行 使用 ANSI 转义序列 Windows 10 之前的 Windows 控制台上不支持 ANSI 颜色 对于 Windows 10 以
  • 如何在 Julia 1.0 中离线安装 julia 包?

    我有自己的 Julia 包 在 Julia 0 6 上运行良好 当我尝试升级到 Julia 1 0 时 我发现在 Julia 1 0 中添加我自己的包更加困难 我不能把它放在 pkg dir 下 在我的情况下 该包只是我本地磁盘上的几个文件
  • 本地 Postgres 应用程序在端口 5432 上运行,但映射到该端口的 Docker Compose 服务运行时没有错误?

    我在 MacOS 上 Postgres 应用程序在默认端口 5432 上运行 I ran docker compose up对于以下docker compose yml version 3 3 services postgresql ima