然后创建 当前路径/data/postgres 文件夹,使用 docker-compose up -d 命令
cing!大功告成……才怪。
1 2 3 4 5 6 7 8
Creating network "joplin_test_default" with the default driver Creating joplin_test_db_1 ... Creating joplin_test_db_1 ... error
ERROR: for joplin_test_db_1 Cannot start service db: driver failed programming external connectivity on endpoint joplin_test_db_1 (785aa7860ddfe145a4b72dd8f88dc516b8bf7af28cacaad96cf5d0f9df719ac7): Error starting userland proxy: listen tcp4 0.0.0.0:5432: bind: address already in use
ERROR: for db Cannot start service db: driver failed programming external connectivity on endpoint joplin_test_db_1 (785aa7860ddfe145a4b72dd8f88dc516b8bf7af28cacaad96cf5d0f9df719ac7): Error starting userland proxy: listen tcp4 0.0.0.0:5432: bind: address already in use ERROR: Encountered errors while bringing up the project.
通过报错得知端口 5432 已经被占用,查了一下是群晖 NAS 自己在 5432 开了个 PostgreSQL 服务。所以讲道理的话我们是可以不用再在 Docker 中启动一个 PostgreSQL 服务,直接用 NAS 自己启动的原生就好了(注意这样要设置 Docker 网络模式为 Host)。不过这背离了我们不把 NAS 当普通 Linux 服务器的初衷,所以只能换一个给 PostgreSQL 换一个端口号
db: Could not connect. Will try again. connect ECONNREFUSED 172.18.0.2:12345 db: Could not connect. Will try again. connect ECONNREFUSED 172.18.0.2:12345 db: Could not connect. Will try again. connect ECONNREFUSED 172.18.0.2:12345 [error] db: Timeout trying to connect to database: Error: connect ECONNREFUSED 172.18.0.2:12345 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) { errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '172.18.0.2', port: 12345 } Error: Timeout trying to connect to database. Last error was: connect ECONNREFUSED 172.18.0.2:12345 at Object.<anonymous> (/home/joplin/packages/server/src/db.ts:113:10) at Generator.next (<anonymous>) at fulfilled (/home/joplin/packages/server/dist/db.js:5:58) at processTicksAndRejections (node:internal/process/task_queues:96:5)