ios - 带有端口映射的 docker-compose 中的 iOS postgres
问题描述
我有以下码头工人组成:
version: '3'
services:
postgres:
container_name: test-psql
image: postgres:10.4-alpine
restart: always
ports:
- 5432:5432
volumes:
- ~/docker_data/postgres:/data/postgres
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
我开始一切,docker-compose up
然后docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f4cae94afaa6 postgres:10.4-alpine "docker-entrypoint.s…" 48 seconds ago Up 47 seconds 0.0.0.0:5432->5432/tcp test-psql
但是当试图连接到它时psql
psql -h localhost -U test
我得到错误
psql: could not connect to server: Connection refused
Is the server running on host “localhost” (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host “localhost” (127.0.0.1) and accepting
TCP/IP connections on port 5432?
解决方案
你正在尝试的是正确的 - 我在我的最后测试了它以防万一它按预期工作。我建议检查您的防火墙配置。
推荐阅读
- android - Nougat+ 上的 WebView 不呈现或加载页面
- java - AWS Datapipeline 不正确的 java 版本
- python - 如何在熊猫中转换json对象数组
- javascript - Three.js 碰撞检测不适用于纹理
- ada - 阿达编程。Put 和 Put_line 有什么区别
- mongodb - Meteor Collection Hooks 错误:“Collection<>”类型上不存在属性“之前”
- java - 如何在 POST 请求中向其他 Feign 客户端发出 GET 请求?
- laravel - Laravel 黄昏断言 404 错误
- javascript - Gatsbyjs _ Redux - 如何为 Gatsby 的项目提供全局存储?
- r - 如何为数据框中的数据列表拆分或创建新列?