[英]Docker Postgres and Adminer accept connection but doesn't work
On my rasperry pi 4 I've installed docker and docker-compose and now I'm tring to install and use Postgres and Adminer following that https://hub.docker.com/_/postgres I've created docker-compose.yaml file as follow:在我的树莓派 4 上,我已经安装了 docker 和 docker-compose,现在我正在尝试在https://hub.docker.com/_/postgres之后安装和使用 Postgres 和 Adminer,我已经创建了 docker-compose。 yaml 文件如下:
# Use postgres/example user/password credentials
version: '3.1'
services:
db:
image: postgres
restart: unless-stopped
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
adminer:
image: adminer
restart: unless-stopped
ports:
- 8080:8080
and i run it with我用它运行它
docker-compose -f docker-compose.yaml up -d
after that DB_1 starts and adminer too but when i try connect to http://192.168.1.38:8080/ i can't reach it even if i try connect to postgres through pgAdmin it's says之后 DB_1 也启动和管理,但是当我尝试连接到http://192.168.1.38:8080/时,即使我尝试通过 pgAdmin 连接到 postgres,我也无法访问它。
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "192.168.1.38" and accepting TCP/IP connections on port 5432?
无法连接到服务器:连接被拒绝 (0x0000274D/10061) 服务器是否在主机“192.168.1.38”上运行并接受端口 5432 上的 TCP/IP 连接?
however if i don't use docker-compose but just但是,如果我不使用 docker-compose 而只是
docker run --name postgres -d --restart unless-stopped -p 5432:5432 -e POSTGRES_PASSWORD=123456 -v ${PWD}/data:/var/lib/postgresql/data postgres
it's work through pgAdmin它是通过 pgAdmin 工作的
do you know what i'm doing wrong?你知道我在做什么错吗?
UPDATE: seems the problem is with docker-compose because any kind of docker-compose.yml file block connection to it...更新:似乎问题出在 docker-compose 因为任何类型的 docker-compose.yml 文件都会阻止与它的连接......
with a container with djgango i tried to start server and it's works but when i try reach page it seem bloccked too使用带有 djgango 的容器我尝试启动服务器并且它可以工作但是当我尝试到达页面时它似乎也被阻塞了
when i run docker-compose.yaml file docker-compose ps output is:当我运行 docker-compose.yaml 文件 docker -compose ps输出是:
PgAdmin can't reach 5432 ports because you don't expose it. PgAdmin 无法访问 5432 端口,因为您没有公开它。 Like for Adminer you need to expose the Postgres port 5432 on your machine in your compose file.
与管理员一样,您需要在您的撰写文件中公开您机器上的 Postgres 端口 5432。
version: '3.1'
services:
db:
image: postgres
restart: unless-stopped
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
adminer:
image: adminer
restart: unless-stopped
ports:
- 8080:8080
聚会有点晚了,但您需要做的是找出 postgres 容器的 IP 地址,并将其用作您的主机。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.