【发布时间】:2018-05-27 12:39:40
【问题描述】:
我有以下 docker-compose.yml 文件来使用 postgresql 运行 kong。我也有迁移,我现在已经删除了。想知道为什么它会抛出 postgresql 的连接问题。
- postgresql 容器已启动并正在运行。
- 问题出在孔中
这是我的 docker-compose.yml:
version: '3.2'
networks:
kong-net:
services:
kong-database:
image: postgres:9.5
container_name: kong-database
networks:
- kong-net
ports:
- 5435:5435
environment:
- POSTGRES_DB=kong
- POSTGRES_USER=kong
- POSTGRES_PASSWORD=password
kong:
image: kong:latest
restart: always
networks:
- kong-net
depends_on:
- kong-database
ports:
- 8000:8000
- 8443:8443
- 8009:8009
- 7947:7947
- 7947:7947/udp
environment:
- KONG_DATABASE=postgres
- KONG_PG_HOST=kong-database
- KONG_PG_PASSWORD=password
- KONG_ADMIN_LISTEN=0.0.0.0:8009
我正在更改 kong 的端口,因为已经有其他一些服务 在 8001 端口运行
这是来自docker-compose logs的错误日志
日志:
Attaching to kong_kong_1, kong-database
kong-database | The files belonging to this database system will be owned by user "postgres".
kong-database | This user must also own the server process.
kong-database |
kong-database | The database cluster will be initialized with locale "en_US.utf8".
kong-database | The default database encoding has accordingly been set to "UTF8".
kong-database | The default text search configuration will be set to "english".
kong-database |
kong-database | Data page checksums are disabled.
kong-database |
kong-database | fixing permissions on existing directory /var/lib/postgresql/data ... ok
kong-database | creating subdirectories ... ok
kong-database | selecting default max_connections ... 100
kong-database | selecting default shared_buffers ... 128MB
kong-database | selecting dynamic shared memory implementation ... posix
kong-database | creating configuration files ... ok
kong-database | creating template1 database in /var/lib/postgresql/data/base/1 ... ok
kong-database | initializing pg_authid ... ok
kong-database | initializing dependencies ... ok
kong-database | creating system views ... ok
kong-database | loading system objects' descriptions ... ok
kong-database | creating collations ... ok
kong-database | creating conversions ... ok
kong-database | creating dictionaries ... ok
kong-database | setting privileges on built-in objects ... ok
kong-database | creating information schema ... ok
kong-database | loading PL/pgSQL server-side language ... ok
kong-database | vacuuming database template1 ... ok
kong-database | copying template1 to template0 ... ok
kong-database | copying template1 to postgres ... ok
kong_1 | prefix directory /usr/local/kong not found, trying to create it
kong_1 | nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:169: [postgres error] could not retrieve server_version: connection refused
kong_1 | stack traceback:
kong_1 | [C]: in function 'error'
kong_1 | /usr/local/share/lua/5.1/kong/init.lua:169: in function 'init'
kong_1 | init_by_lua:3: in main chunk
kong_1 | nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:169: [postgres error] could not retrieve server_version: connection refused
kong_1 | stack traceback:
kong_1 | [C]: in function 'error'
kong_1 | /usr/local/share/lua/5.1/kong/init.lua:169: in function 'init'
kong_1 | init_by_lua:3: in main chunk
【问题讨论】:
标签: postgresql docker docker-compose kong