1. Environment Description
-
System version: CentOS8
-
Docker: Docker CE 19.03.14 Using Tencent Image source Installation
-
Server IP address: 192.168.0.21
-
Docker Mirroring version: Postgres :9.6 / Kong :2.2.1- Alpine/Pantsel/Konga: Next
2. Configure the firewall
The Docker container uses Bridge by default. Configure Firewalld to trust the Docker IP address
- Check the subnet
$ docker network inspect bridge
Copy the code
Where Subnet is the corresponding container Subnet. For example, “Subnet”: “172.17.0.0/16”
- configuration
$firewall-cmd --zone=trusted --add-source=172.17.0.0/16 --permanent $firewall-cmd --reloadCopy the code
You can also add an interface directly, for example
$ firewall-cmd --zone=trusted --add-interface=docker0 --permanent
$ firewall-cmd --reload
Copy the code
3. Install postgres
Install PostgreSQL using Docker. Default user is kong, database kong, password 123456. Run the mkdir -p /opt/docker-data/postgres command to create a directory
$ docker run -d --name kong-database \ -p 5432:5432 \ -e "POSTGRES_USER=kong" \ -e "POSTGRES_DB=kong" \ -e "POSTGRES_PASSWORD = 123456 \" - v/opt/docker - data/postgres: / var/lib/postgresql/data \ postgres: 9.6Copy the code
4. Install Kong
- Initialize the Kong database (create tables)
$docker run --rm \ -e "KONG_DATABASE=postgres" \ -e "KONG_PG_HOST=192.168.0.21" \ -e "KONG_PG_PORT=5432" \ -e "KONG_PG_USER=kong" \ -e "KONG_PG_PASSWORD=123456" \ -e "KONG_PG_DATABASE=kong" \ kong:2.2.1-alpine kong migrations bootstrapCopy the code
- Install Kong
$docker run -d --name kong \ -e "KONG_DATABASE=postgres" \ -e "KONG_PG_HOST=192.168.0.21" \ -e "KONG_PG_PORT=5432" \ -e "KONG_PG_USER=kong" \ -e "KONG_PG_PASSWORD=123456" \ -e "KONG_PG_DATABASE=kong" \ -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 \ -p 8000-8000, 8443:8443 \ -p 8001:8001 \ -p 8444:8444 \ kong: 2.2.1 - alpineCopy the code
4. Install Konga
Install the third-party management UI
- Initializing the database
Create and initialize the KongA database. If the tables have changed since the version update, this method will also update the tables
$docker run --rm Pantsel /konga:next -c prepare -a postgres -u postgresQL ://kong:[email protected]:5432/kongaCopy the code
- Install Konga
$docker run -d -p 1337:1337 \ -e "DB_ADAPTER=postgres" \ -e "DB_HOST=192.168.0.21" \ -e "DB_PORT=5432" \ -e "DB_USER=kong" \ -e "DB_PASSWORD=123456" \ -e "DB_DATABASE=konga" \ -e "NODE_ENV=production" \ --name konga \ pantsel/konga:nextCopy the code
- Open port 1337
For the convenience of testing, open 1337 public access. It is not recommended to open public access in the actual build environment deployment. You can restrict IP access on the management machine
$ firewall-cmd --add-port=1337/tcp --permanent
$ firewall-cmd --reload
Copy the code
- test
Visit http://192.168.0.21:1337, log in and add the management end Kong Admin URL http://192.168.0.21:8001, the connection is successful as follows