docker-compose.yml内容
官网没说密码这个情况,我通过测试验证,是需要增加密码参数的。
version: "3" networks: kong-net: driver: bridge services: ####################################### # Postgres: The database used by Kong ####################################### kong-database: image: postgres:9.6 restart: always networks: - kong-net environment: POSTGRES_USER: username POSTGRES_DB: dbname POSTGRES_PASSWORD: psql_password #必须准备一个密码。不然启动报错 ports: - "5432:5432" volumes: - /opt/kong/kong-database:/var/lib/postgresql/data healthcheck: test: ["CMD", "pg_isready", "-U", "kong"] interval: 5s timeout: 5s
retries: 5 ####################################### # Kong database migration ####################################### kong-migration: image: kong:latest command: "kong migrations bootstrap" networks: - kong-net restart: on-failure environment: KONG_PG_HOST: kong-database KONG_DATABASE: postgres KONG_PG_PASSWORD: psql_password #必须加上,不然连接数据库失败导致初始化会失败 KONG_CASSANDRA_CONTACT_POINTS: kong-database links: - kong-database depends_on: - kong-database ####################################### # Kong: The API Gateway ####################################### kong: image: kong:latest restart: always networks: - kong-net environment: KONG_PG_HOST: kong-database KONG_PROXY_LISTEN: 0.0.0.0:8000 KONG_PROXY_LISTEN_SSL: 0.0.0.0:8443 KONG_ADMIN_LISTEN: 0.0.0.0:8001 KONG_DATABASE: postgres KONG_PG_PASSWORD: psql_password #必须加上密码,不然连接数据库失败 KONG_CASSANDRA_CONTACT_POINTS: kong-database depends_on: - kong-migration - kong-database healthcheck: test: ["CMD", "curl", "-f", "http://kong:8001"] interval: 5s timeout: 2s retries: 15 ports: - "8001:8001" - "8000:8000" - "8443:8443" # volumes: 若有配置文件要自己配置,则建议挂在出来 # - /opt/kong/kong.conf:/etc/kong/kong.conf ####################################### # Konga database prepare ####################################### konga-prepare: image: pantsel/konga:next command: "-c prepare -a postgres -u postgresql://username:psql_password@kong-database:5432/konga_db" #注意是用户名:密码@数据库服务名称:端口 networks: - kong-net restart: on-failure links: - kong-database depends_on: - kong-database ####################################### # Konga: Kong GUI ####################################### konga: image: pantsel/konga:latest #restart: always networks: - kong-net environment: DB_ADAPTER: postgres DB_HOST: kong-database DB_USER: username TOKEN_SECRET: km1GUr4RkcQD7DewhJPNXrCuZwcKmqjb DB_DATABASE: konga_db NODE_ENV: production DB_PASSWORD: psql_password #必须加上密码,不然会失败 depends_on: - kong-database ports: - "1337:1337"
验证:http://ip:1337访问