How can I add a customized kong plugin into dockerized kong
I tried to do same thing but could not found well-describe answer yet.You can configure simple helloworld plugin as below: (https://github.com/brndmg/kong-plugin-hello-world)
Local 'plugin' directory structure on Docker host:
Then you can mount local /plugins directory and let kong load custom 'helloworld' plugin from /plugins directory
1) using environment variables
$ docker run -d --name kong --network=kong-net \-e "KONG_DATABASE=cassandra" \-e "KONG_PG_HOST=kong-database" \ -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \**-e "KONG_LUA_PACKAGE_PATH=/plugins/?.lua" \-e "KONG_CUSTOM_PLUGINS=helloworld" \ ** ...-e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \**-v "/plugins:/plugins" \**-p 8080:8000 -p 8443:8443 -p 8001:8001 -p 8444:8444 kong:latest
Then, you can see configured custom plugin on http://[kong-url]:8001/
.."custom_plugins": ["helloworld"],..
2) Or, you can simple mount your custom kong.conf file which describes plugins you want.
/etc/kong/kong.conf
plugins = bundled,helloworld,jwt-crafter
(It seems that second option is better for latest version of Kong because 'kong_custom_plugin' configuration prints 'deprecation' warning)
For the JWT crafter, https://github.com/foodora/kong-plugin-jwt-crafterit seems that the plugin is not maintained well so that installation using luarocks failed with errors.
$ luarocks install kong-plugin-jwt-crafter....kong-plugin-jwt-crafter 1.0-0 depends on lua-resty-jwt ~> 0.1.10-1 (not installed)Error: Could not satisfy dependency lua-resty-jwt ~> 0.1.10-1: No results matching query were found.
Instead, you can directly to add 'resty-jwt' to official docker image, to resolve dependency, which is not included in official image. and copy "JWT crafter" into "/plugins" directory, and load.
(Inside docker container)
luarocks install lua-resty-jwt
Hope this helps.
you can generate a new docker image containing the plugin using https://github.com/Kong/docker-kong/tree/master/customize
See the example (https://github.com/Kong/docker-kong/blob/master/customize/example.sh) on how to do this without having the source code publicly available on LuaRocks.