在docker中运行kong和kong dashboard

一、制作alpine版的kong镜像

https://github.com/Kong/docker-kong/tree/d4cec3dc46c780a916a40963309554ca81da2b46/alpine
需要修改Dockerfile,增加执行权限,否则会报错:

Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"/docker-entrypoint.sh\\\": permission denied\"\n".

修改后Dockerfile为:

FROM alpine:3.6
LABEL maintainer Marco Palladino, marco@mashape.com

ENV KONG_VERSION 0.12.1
ENV KONG_SHA256 9f699e20e7d3aa6906b14d6b52cae9996995d595d646f9b10ce09c61d91a4257

RUN apk add --no-cache --virtual .build-deps wget tar ca-certificates \
        && apk add --no-cache libgcc openssl pcre perl tzdata \
        && wget -O kong.tar.gz "https://bintray.com/kong/kong-community-edition-alpine-tar/download_file?file_path=kong-community-edition-$KONG_VERSION.apk.tar.gz" \
        && echo "$KONG_SHA256 *kong.tar.gz" | sha256sum -c - \
        && tar -xzf kong.tar.gz -C /tmp \
        && rm -f kong.tar.gz \
        && cp -R /tmp/usr / \
        && rm -rf /tmp/usr \
        && cp -R /tmp/etc / \
        && rm -rf /tmp/etc \
        && apk del .build-deps

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 8000 8443 8001 8444

STOPSIGNAL SIGTERM

CMD ["/usr/local/openresty/nginx/sbin/nginx", "-c", "/usr/local/kong/nginx.conf", "-p", "/usr/local/kong/"]
~                                                                                                               

二、Tag后push到私有镜像仓库

docker tag  kong:0.12.1-alpine xx.xx.xx.xx:5000/kong:0.12.1-alpine
docker push xx.xx.xx.xx:5000/kong:0.12.1-alpine

三、准备,并运行kong,

可参考:https://getkong.org/install/docker/?_ga=2.142464946.1094900129.1519568988-2071034501.1509695831

先运行postgres数据库

docker run -d --name kong-database \
              -p 5432:5432 \
              -e "POSTGRES_USER=kong" \
              -e "POSTGRES_DB=kong" \
              postgres:9.4

迁移数据

docker run --rm \
    --link kong-database:kong-database \
    -e "KONG_DATABASE=postgres" \
    -e "KONG_PG_HOST=kong-database" \
    -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
    kong:0.12.1-alpine kong migrations up

运行Kong

docker run -d --name kong \
    --link kong-database:kong-database \
    -e "KONG_PG_HOST=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" \
    -e "KONG_ADMIN_LISTEN_SSL=0.0.0.0:8444" \
    -p 8000:8000 \
    -p 8443:8443 \
    -p 8001:8001 \
    -p 8444:8444 \
    Kong:0.12.1-alpine

运行kong dashboard

参考:https://github.com/PGBI/kong-dashboard

docker run --name kong-dashboard -d -p 8084:8080 pgbi/kong-dashboard:v2
posted @ 2018-02-26 01:10 ikoDotA 阅读(...) 评论(...) 编辑 收藏
ikoDotA's 新浪微博