我正在尝试编写kong api网关的 docker-compose 文件,我可以将其用作在docker swarm模式下运行的docker节点中的堆栈部署。
kong有自己的官方docker-compose文件,但不幸的是 正在使用版本2.1,因此我必须删除一些功能,如 取决于条件。
Bellow是docker-compose.yml我写的是为了使它与docker stack兼容。 问题是,迁移服务无效
version: '3.4'
networks:
net-kong:
services: consul:
image: progrium/consul:latest networks:
- net-kong command: -server -bootstrap -ui-dir /ui healthcheck:
test: ["CMD-SHELL", "curl -I -s -L http://127.0.0.1:8500 || exit 1"]
interval: 5s
retries: 10
ports:
- 8500:8500
expose:
- 53
- 8300
- 8301
- 8302
- 8400
- 8500
dns:
- 127.0.0.1
nginx-lb:
image: nginx:kong
networks:
- net-kong
depends_on:
- consul
ports:
- 8000:8000
- 8443:8443
- 8001:8001
- 8444:8444
expose:
- 8000
- 8443
- 8001
- 8444
links:
- consul:consul
command: >
/bin/containerpilot
-config file:///etc/containerpilot/containerpilot.json
nginx -g "daemon off;"
kong-database:
image: postgres:9.5
networks:
- net-kong
environment:
- POSTGRES_USER=kong
- POSTGRES_DB=kong
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 10s
timeout: 5s
retries: 5
kong-migration:
image: kong
networks:
- net-kong
depends_on:
- kong-database
environment:
- KONG_DATABASE=postgres
- KONG_PG_HOST=kong-database
command: kong migrations up
kong:
image: kong
networks:
- net-kong
depends_on:
- kong-database
- kong-migration
environment:
- KONG_DATABASE=postgres
- KONG_PG_HOST=kong-database
- KONG_PG_DATABASE=kong
- KONG_ADMIN_LISTEN=0.0.0.0:8001
expose:
- 8000
- 8001
- 8443
- 8444
healthcheck:
test: ["CMD-SHELL", "curl -I -s -L http://127.0.0.1:8000 || exit 1"]
interval: 5s
retries: 10
根据我的理解,它不起作用,因为迁移正在尝试 在数据库服务运行之前运行。这将导致 错误。请指导我。
迁移不起作用,甚至日志在输入时也没有显示任何内容。docker service logs service-name