如何解决Docker:PostgrSQL 数据库的管理员后端超时
我正在尝试使用 PostgreSQL Docker 容器和 Adminer 容器作为后端来建立一个简单的数据库系统。请注意,这一切都在 RaspberryPi 4 上运行。
docker-compose.yml
:
services:
postgres:
image: postgres
restart: on-failure
ports:
- 5432:5432
env_file:
- ./.auth_file
volumes:
- db:/var/lib/postgresql/data
adminer:
image: adminer
restart: on-failure
ports:
- 8070:8080
env_file:
- ./.auth_file
depends_on:
- postgres
volumes:
db:
然后我使用 docker-compose up
运行它:
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | 2021-04-01 13:25:25.919 UTC [1] LOG: starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on arm-unknown-linux-gnueabihf,compiled by gcc (Debian 8.3.0-6) 8.3.0,32-bit
postgres_1 | 2021-04-01 13:25:25.919 UTC [1] LOG: listening on IPv4 address "0.0.0.0",port 5432
postgres_1 | 2021-04-01 13:25:25.919 UTC [1] LOG: listening on IPv6 address "::",port 5432
postgres_1 | 2021-04-01 13:25:26.028 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2021-04-01 13:25:26.090 UTC [27] LOG: database system was shut down at 2021-04-01 13:20:41 UTC
postgres_1 | 2021-04-01 13:25:26.116 UTC [1] LOG: database system is ready to accept connections
adminer_1 | [Sun Jun 14 00:31:20 2071] PHP 7.4.16 Development Server (http://[::]:8080) started
adminer_1 | [Sun Jun 14 00:30:16 2071] [::ffff:192.168.16.1]:50886 Accepted
最后一行显示我试图在 Pi 上的浏览器中访问 localhost:8070
。该页面永远加载,Adminer 永远不会返回该页面。
这可能与某些防火墙问题有关吗?
感谢您的帮助!
解决方法
找到了解决方案。这与 Docker 容器无法从主机获取当前时间有关,因为 Docker、Alpine(Adminer 的基本映像)和 libseccomp
存在一些版本问题。这一点也很明显,因为 Adminer 显示的时间戳与我原帖中的 Postgres-Container 完全不同。
完整的解释可以在这里找到:https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.13.0#time64_requirements
按照上面链接的步骤操作后,docker-compose.yml
应如下所示:
adminer:
image: adminer
...
security_opt:
- seccomp=config/compose/default.json # required to avoid clock_gettime() errors
将 config/compose/default.json
替换为修改后的 default.json
的相对路径。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。