The hook config json needs to be placed in the platform hook config directory. Example configuration paths:
/usr/share/containers/oci/hooks.d
/etc/containers/oci/hooks.d
Building
go build -o bin/hook hook.go
Using it with Kata Containers
Ensure guest_hook_path is set to /usr/share/oci/hooks in kata containers configuration.toml file.
Additionally also set kernel_params = "agent.debug_console" which will allow access to the hook logs inside the Kata VM
Copy the hook binary to the Kata agent initrd under the following location ${ROOTFS_DIR}/usr/share/oci/hooks/prestart
Instructions to build a custom Kata agent is described here
For quick experimentation, you can find a sample kata initrd for amd64 in the following container image bpradipt/kata-initrd-hook
In order to extract the initrd you can use the following steps: