1, sudo docker network create kong-net
2, sudo docker run -d --name kong-database --network=kong-net -p 5432:5432 -e "POSTGRES_USER=kong" -e "POSTGRES_DB=kong" -e "POSTGRES_PASSWORD=kong" postgres:9.6
(注意:password是必須設(shè)置的,還可以設(shè)置"POSTGRES_HOST_AUTH_METHOD=trust")
如果不設(shè)置postgres_password,會(huì)出現(xiàn)如下bug
Error: Database is uninitialized and superuser password is not specified.
?????? You must specify POSTGRES_PASSWORD to a non-empty value for the
?????? superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
?????? You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
?????? connections without a password. This is *not* recommended.
?????? See PostgreSQL documentation about "trust":
?????? https://www.postgresql.org/docs/current/auth-trust.html
3, sudo docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_PG_USER=kong" -e "KONG_PG_PASSWORD=kong" -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" kong/kong kong migrations bootstrap
4, sudo docker run -d --name kong --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_PG_PASSWORD=kong" -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/kong
5, sudo docker run -d -p 1337:1337 --network kong-net -e "TOKEN_SECRET=kongtoken" -e "DB_ADAPTER=postgres" -e "DB_HOST=kong-database" -e "DB_USER=kong"? -e "DB_PASSWORD=kong" --name konga pantsel/konga
6, 訪問http://服務(wù)器IP:1337,首次登錄會(huì)需要先注冊(cè)admin,然后進(jìn)入登錄頁(yè)面,然后再填url地址;填kong和http://kong:8001即可連接進(jìn)入
