docker安装kong

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker安装kong相关的知识,希望对你有一定的参考价值。

Create a Docker network
You will need to create a custom network to allow the containers todiscover and communicate with each other. In this examplekong-netis thenetwork name, you can use any name.


$ docker network create kong-net

Start your database

If you wish to use a Cassandra container:

$ docker run -d --name kong-database               --network=kong-net               -p 9042:9042               cassandra:3

If you wish to use a PostgreSQL container:

$ docker run -d --name kong-database               --network=kong-net               -p 5432:5432               -e "POSTGRES_USER=kong"               -e "POSTGRES_DB=kong"               postgres:9.6

Prepare your database

Run the migrations with an ephemeral Kong container:

$ docker run --rm     --network=kong-net     -e "KONG_DATABASE=postgres"     -e "KONG_PG_HOST=kong-database"     -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database"     kong:latest kong migrations up

In the above example, both Cassandra and PostgreSQL are configured, but youshould update theKONG_DATABASEenvironment variable with eithercassandraorpostgres.

Note: migrations should never be run concurrently; onlyone Kong node should be performing migrations at a time.

Start Kong

When the migrations have run and your database is ready, start a Kongcontainer that will connect to your database container, just like theephemeral migrations container:

$ docker run -d --name kong     --network=kong-net     -e "KONG_DATABASE=postgres"     -e "KONG_PG_HOST=kong-database"     -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database"     -e "KONG_PROXY_ACCESS_LOG=/dev/stdout"     -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout"     -e "KONG_PROXY_ERROR_LOG=/dev/stderr"     -e "KONG_ADMIN_ERROR_LOG=/dev/stderr"     -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl"     -p 8000:8000     -p 8443:8443     -p 8001:8001     -p 8444:8444     kong:latest

Use Kong

Kong is running:

$ curl -i http://localhost:8001/


UI install

docker run -d --name kong-dashboard     --network=kong-net     -p 8080:8080     pgbi/kong-dashboard:v2 migrations up
http://localhost:8080

以上是关于docker安装kong的主要内容,如果未能解决你的问题,请参考以下文章

1. 使用 Docker 安装 Kong

安装了 Deck 的 Docker Compose Kong

docker安装kong

Kong环境搭建(一)

linux 安装kong gateway

网关服务Kong、Konga搭建记录