Hotdog is a set of OCI hooks used to inject the Log4j Hot Patch into containers.
When runc sets up the container, it invokes hotdog-cc-hook
. hotdog-cc-hook
bind-mounts the hotpatch files into the container's filesystem at
/dev/shm/.hotdog
. After the main container process starts, runc invokes
hotdog-poststart-hook
, which uses nsenter
to enter the container's
namespaces and fork off a hotdog-hotpatch
process. hotdog-hotpatch
runs
several times with decreasing frequency (currently 1s, 5s, 10s, 30s) to detect
and hotpatch JVMs inside the container.
hotdog-hotpatch
process exits,
they will not be hot patched.hotdog-hotpatch
might remain for a short time after the container exits./dev/shm/.hotdog
inside the container.
If /dev/shm
does not exist (such as in the case of Docker containers
launched with --ipc=none
), hotdog will not be injected into the container
and will not provide hotpatching.Hotdog is included by default in Bottlerocket 1.5.0.
Hotpatching can be enabled for new launches of Bottlerocket by including the following settings in user data.
[settings.oci-hooks]
log4j-hotpatch-enabled = true
For existing hosts running the latest version of Bottlerocket, hotpatching can be enabled using the API client.
apiclient set oci-hooks.log4j-hotpatch-enabled=true
Enabling the setting at runtime has no effect on running containers. Newly-launched containers will be hotpatched.
To install Hotdog, you need to copy the following files to the right location and set the appropriate configuration.
Log4jHotPatch.jar
to /usr/share/hotdog
(if you build the hotpatch
from source, you'll find it in build/libs
)make && sudo make install
to install hotdog-cc-hook
and
hotdog-poststart-hook
to /usr/libexec/hotdog
and hotdog-hotpatch
to
/usr/share/hotdog
oci-add-hooks
oci-add-hooks
with the hotdog hooks by writing the following
contents to /etc/hotdog/config.json
:
{
"hooks": {
"prestart": [{
"path": "/usr/libexec/hotdog/hotdog-cc-hook"
}],
"poststart": [{
"path": "/usr/libexec/hotdog/hotdog-poststart-hook"
}]
}
}
/etc/docker/daemon.json
:
{
"runtimes": {
"hotdog": {
"path": "oci-add-hooks",
"runtimeArgs": [
"--hook-config-path", "/etc/hotdog/config.json",
"--runtime-path", "/usr/sbin/runc"
]
}
}
}
To run a container with hotpatching enabled, specify
docker run --runtime hotdog
. To run with hotpatching enabled by default in
all containers, add the following contents to /etc/docker/daemon.json
:
"default-runtime": "hotdog"
If you wish to opt-out of hotdog
even when it is enabled by default, specify
--runtime runc
.
hotdog
will add several files to the /dev/shm/.hotdog
directory in each
container. You can find the log from hotdog-hotpatch
in
/dev/shm/hotdog.log
.
See CONTRIBUTING for more information.
This project is licensed under the Apache-2.0 License.