linux - 如何对 Linux 上的 PostgreSQL Docker 设置进行故障排除

标签 linux postgresql docker redhat

我能够运行 2 个 docker 容器。我可以看到它们正在运行,但我看不到实际的服务。

我按照步骤 here设置一个新的 postgresql 实例,我可以看到它正在运行:

[vagrant@localhost dev]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                    PORTS                                     NAMES
fe1fd9c362a2        dpage/pgadmin4      "/entrypoint.sh"         15 hours ago        Up 15 hours               80/tcp, 443/tcp, 0.0.0.0:5050->5050/tcp   awesome_yonath
e2dc95062de8        dpage/pgadmin4      "/entrypoint.sh"         15 hours ago        Exited (0) 15 hours ago                                             zealous_boyd
f516085ac3e1        dpage/pgadmin4      "/entrypoint.sh"         15 hours ago        Exited (0) 15 hours ago                                             vibrant_noether
a01d9ec38f17        postgres            "docker-entrypoint.s…"   16 hours ago        Up 16 hours               0.0.0.0:5432->5432/tcp                    pg-docker

然而,当我尝试使用任何 postgres 命令并运行 top 时,我没有看到该服务。

[vagrant@localhost dev]$ psql
bash: psql: command not found...
[vagrant@localhost dev]$ postgres
bash: postgres: command not found...

试图弄清楚我是否需​​要手动启动服务,或者如何解决这个问题

我的安装脚本:

mkdir -p $HOME/docker/volumes/postgres
docker pull postgres:9.6.11
docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data  postgres

最佳答案

如果我理解正确的话,您在 Vagrant 机器中作为主机运行 PostgreSql docker 容器。您无法从主机看到容器中运行的进程。您可以在容器内运行一个交互式 shell 来查看 PostgreSql 服务器进程,运行 top 等等。像这样:

docker exec -it  <pg-container-id> bash

docker exec <pg-container-id> ps

列出进程。

希望对您有所帮助。

关于linux - 如何对 Linux 上的 PostgreSQL Docker 设置进行故障排除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54593984/

相关文章:

arrays - PostgreSQL : How to create a constraint to check an element is not in an array of string

docker - 在 MacOS 上构建的 docker 镜像是否可以部署到 Linux 等其他操作系统?

linux - `epoll_wait` 是否表示同时添加 EPOLLIN 和 EPOLLOUT 时触发了哪个事件?

linux - Oracle 12c Ubuntu 17.04 安装报错

linux - 父 shell 终止后恢复 gdb session

node.js - nodeJS 应用程序中的两阶段提交

linux - 维护用于生产的嵌入式 Linux 系统配置的最佳实践

sql - 如果结果为空,PostgreSQL 不过滤

docker - 在 Docker 容器中部署 Golang 应用程序

node.js - Heroku找不到Playwright文件