0

我正在尝试使用 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

最后一行显示我试图localhost:8070在 Pi 上的浏览​​器中访问。该页面只是永远加载,并且管理员永远不会返回该页面。

这可能与某些防火墙问题有关吗?

谢谢你的帮助!

4

1 回答 1

0

找到了解决方案。这与 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

于 2021-04-02T11:49:32.300 回答