Docker Installation : Docker 中安装并启动 Kong

前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到教程。

Details about how to use Kong in Docker can be found on the DockerHub repository hosting the image: kong. We also have a Docker Compose template with built-in orchestration and scalability.

Here is a quick example showing how to connect a Kong container to a Cassandra or PostgreSQL container:

  1. Create a Docker network

    You will need to create a custom network to allow the containers to discover and communicate with each other. In this example kong-net is the network name, you can use any name.

    $ docker network create kong-net
    
  2. 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
    
  3. 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 you should update the KONG_DATABASE environment variable with either cassandra or postgres.

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

  4. Start Kong

    When the migrations have run and your database is ready, start a Kong container that will connect to your database container, just like the ephemeral 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
    
  5. Use Kong

    Kong is running:

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

    Quickly learn how to use Kong with the 5-minute Quickstart.

转自Docker官网:https://docs.konghq.com/install/docker/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值