postgresql - 将 SSL 证书添加到 docker 容器中的 postgres 数据库

标签 postgresql docker ssl docker-compose

我正在运行来自 this 的 Postgres 数据库docker 容器中的图像。我试图向其中添加 SSL 证书。但是我无法将证书从主机移动到容器。

我什至尝试使用 this以 gist 为例,但我得到如下响应。

Pulling bridge_db (postgres:alpine)...
alpine: Pulling from library/postgres
921b31ab772b: Pull complete
be3c1cbf8f01: Pull complete
59c0d4fd1acf: Pull complete
ac0dfed8036c: Pull complete
a866c759c33e: Pull complete
8166d6656385: Pull complete
b6da096b964f: Pull complete
3fad06bb156c: Pull complete
c48f6f07ba24: Pull complete
Digest:sha256:0058d56b16eda79d34fb7b6987cee0b26df495cb39bbf9a1e2fdab411b08648c
Status: Downloaded newer image for postgres:alpine
Creating core_bridge_db_1
Attaching to core_bridge_db_1
bridge_db_1  | The files belonging to this database system will be owned by user "postgres".
bridge_db_1  | This user must also own the server process.
bridge_db_1  |
bridge_db_1  | The database cluster will be initialized with locale "en_US.utf8".
bridge_db_1  | The default database encoding has accordingly been set to "UTF8".
bridge_db_1  | The default text search configuration will be set to "english".
bridge_db_1  |
bridge_db_1  | Data page checksums are disabled.
bridge_db_1  |
bridge_db_1  | fixing permissions on existing directory /var/lib/postgresql/data ... ok
bridge_db_1  | creating subdirectories ... ok
bridge_db_1  | selecting default max_connections ... 100
bridge_db_1  | selecting default shared_buffers ... 128MB
bridge_db_1  | selecting default timezone ... UTC
bridge_db_1  | selecting dynamic shared memory implementation ... posix
bridge_db_1  | creating configuration files ... ok
bridge_db_1  | running bootstrap script ... ok
bridge_db_1  | performing post-bootstrap initialization ... sh: locale:    not found
bridge_db_1  | 2019-06-26 22:24:17.643 UTC [27] WARNING:  no usable system locales were found
bridge_db_1  | ok
bridge_db_1  | syncing data to disk ... ok
bridge_db_1  |
bridge_db_1  | Success. You can now start the database server using:
bridge_db_1  |
bridge_db_1  |     pg_ctl -D /var/lib/postgresql/data -l logfile start
bridge_db_1  |
bridge_db_1  |
bridge_db_1  | WARNING: enabling "trust" authentication for local connections
bridge_db_1  | You can change this by editing pg_hba.conf or using the option -A, or
bridge_db_1  | --auth-local and --auth-host, the next time you run initdb.
bridge_db_1  | waiting for server to start....2019-06-26 22:24:18.202 UTC [31] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
bridge_db_1  | 2019-06-26 22:24:18.218 UTC [32] LOG:  database system was shut down at 2019-06-26 22:24:17 UTC
bridge_db_1  | 2019-06-26 22:24:18.221 UTC [31] LOG:  database system is ready to accept connections
bridge_db_1  |  done
bridge_db_1  | server started
bridge_db_1  | CREATE DATABASE
bridge_db_1  |
bridge_db_1  |
bridge_db_1  | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
bridge_db_1  |
bridge_db_1  | 2019-06-26 22:24:18.557 UTC [31] LOG:  received fast shutdown request
bridge_db_1  | waiting for server to shut down....2019-06-26 22:24:18.558 UTC [31] LOG:  aborting any active transactions
bridge_db_1  | 2019-06-26 22:24:18.558 UTC [31] LOG:  background worker "logical replication launcher" (PID 38) exited with exit code 1
bridge_db_1  | 2019-06-26 22:24:18.559 UTC [33] LOG:  shutting down
bridge_db_1  | 2019-06-26 22:24:18.568 UTC [31] LOG:  database system is shut down
bridge_db_1  |  done
bridge_db_1  | server stopped
bridge_db_1  |
bridge_db_1  | PostgreSQL init process complete; ready for start up.
bridge_db_1  |
bridge_db_1  | 2019-06-26 22:24:18.667 UTC [1] FATAL:  could not load server certificate file "/var/lib/postgresql/server.crt": no start line
bridge_db_1  | 2019-06-26 22:24:18.667 UTC [1] LOG:  database system is shut down
core_bridge_db_1 exited with code 1

最佳答案

查看您的server.crt中的第一行

它应该只是:

-----BEGIN CERTIFICATE-----

查看该行中是否有更多或更少的内容。(也许是 ^M Charachter?)

我建议使用dos2unix将crt文件转换为unix格式。

关于postgresql - 将 SSL 证书添加到 docker 容器中的 postgres 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56781812/

相关文章:

memory-leaks - 服务的BandwidthIn和BandwidthOut图代表什么?

authentication - 使用 HTTPS 进行客户端-服务器通信

php - 某些浏览器中 cookie 的未定义索引

reactjs - 如果未填写所有字段,如何向数据库添加记录?

docker - 如何在docker上的cassandra中设置堆内存

asp.net - 使用 IE 通过 https(SSL) 导出到 excel 在 asp.net 网站中不起作用

regex - 为特定网址强制使用 HTTPS

postgresql - 如何使用 pgAdmin 创建枚举?

java - Log4j2 属性文件 JDBC 附加程序 - 将上下文变量转换为 uuid

javascript - 无法对 NodeApp 进行 dockerize