How to use the decK docker container.
How to use the `decK` docker container
How do I use the decK Docker container to manage Kong configuration?
Run the official kong/deck Docker image with docker run, mounting a local directory as a volume and pointing --kong-addr at your Kong Admin API. From there you can use dump, sync, reset, and validate the same as a locally installed decK binary.
Overview
Steps
Assuming Kong is running locally and using the default port, the examples below use http://host.docker.internal:8001 as the endpoint of the Kong Admin API for the decK container. Replace this value with your actual Kong Admin API URL.
-
Pull the image:
docker pull kong/deck -
Check available commands:
docker run kong/deck --help -
Run
--helpwith each command to check available flags:docker run kong/deck dump --help docker run kong/deck sync --help docker run kong/deck reset --help ... -
Run
deck dumpto exportkong.yaml. The file is generated in$(pwd)/kong.yaml:docker run -i \ -v $(pwd):/deck \ kong/deck --kong-addr http://host.docker.internal:8001 --headers kong-admin-token:<admin-token> -o /deck/kong.yaml dump -
Run
deck dumpto export declarative configuration files for all workspaces. The files are generated in$(pwd)/.Note: if you run more than one
dumpinto the same directory,decKwill similarly prompt to confirm overwriting existing files, which fails the same way underdocker run -iwithout a TTY (Error: EOF). Unlikereset,dumphas no-f/--forceflag at all (passing one fails withError: unknown shorthand flag: 'f' in -f) - remove or rename the existing output file(s) before re-runningdumpinstead.docker run -i \ -v $(pwd):/deck \ --workdir /deck \ kong/deck --kong-addr http://host.docker.internal:8001 --headers kong-admin-token:<admin-token> dump --all-workspaces -
Run
deck resetto reset the Kong objects to their initial state.Note:
resetprompts for an interactive confirmation, which cannot be answered when running underdocker run -iwithout a TTY (it fails withError: EOF). Pass-f/--forceto skip the prompt.docker run -i \ -v $(pwd):/deck \ kong/deck --kong-addr http://host.docker.internal:8001 --headers kong-admin-token:<admin-token> reset -f -
Run
deck syncto importkong.yaml. This example assumeskong.yamlis in$(pwd)/kong.yaml:docker run -i \ -v $(pwd):/deck \ kong/deck --kong-addr http://host.docker.internal:8001 --headers kong-admin-token:<admin-token> -s /deck/kong.yaml sync -
Run
deck validateto validatekong.yaml. This example assumeskong.yamlis in$(pwd)/kong.yaml:docker run -i \ -v $(pwd):/deck \ kong/deck --kong-addr http://host.docker.internal:8001 --headers kong-admin-token:<admin-token> validate --online -s /deck/kong.yaml