我有一个使用内容运行Dockerfile的Kong实例:

FROM kong:1.4.0

WORKDIR /files
COPY plugins kong/plugins
ENV KONG_LOG_LEVEL=debug
ENV KONG_PLUGINS custom-plugin
ENV KONG_LUA_PACKAGE_PATH /files/?.lua;;

但是,在docker run上,这将返回
error loading plugin schemas: on plugin 'custom-plugin': custom-plugin plugin is enabled but not installed;

module 'kong.plugins.custom-plugin.handler' not found:No LuaRocks module found for kong.plugins.custom-plugin

我已经确认文件的结构正确,并且在运行时嵌套在kong / plugins目录中。

谁能帮助解决这个问题?

最佳答案

checkout 这些资源:

  • https://github.com/luarocks/luarocks/wiki/installation-instructions-for-unix
  • https://luarocks.org/
  • https://luarocks.org/modules/seifchen/kong-path-whitelist
  • https://github.com/Kong/kong/issues/4696

  • kong的错误报告: https://github.com/Kong/kong/issues/4696
    I don't think it's the luarocks' problem
    Indeed, I installed kong in docker whose image is built by a dockerfile.
    In my docker file, I went into the folder which store the custom plugins,and then traverse and luarocks make them by shell.It looks like:
    
    #install private plugins
    cd APIGPlugins
    
    for dir in `ls`; do
        if [ -d $dir ]; then
          cd $dir;
          luarocks make;
          cd ../;
        fi
    done
    and then, I run the docker images for a container by the directive:
    
    sudo docker run -d --name kong \
        -e "KONG_DATABASE=off" \
        -e "KONG_DECLARATIVE_CONFIG=/etc/kong/kong.yml" \
        -e "KONG_PLUGINS=apig-response-transform" \
        -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-plugin:v4
    As u see, I set the kong plugin by the docker run env variable parameter for enable the plugin instead of setting in the kong.conf.
    The logs were generated by directive of docker logs "container ID"
    It works when I tried to install another custom plugin in this way,but not work when install the custom plugin I described before
    

    更新资料

    您需要安装lua软件包管理器luarocks
  • Documentaton Link
  • Download Link
  • 关于docker - Kong-返回的自定义插件:自定义插件已启用但未安装;,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58944475/

    10-16 11:35