18.7. Using Podman events for auditing
Previously, the events had to be connected to an event to interpret them correctly. For example, the container-create event had to be linked with an image-pull event to know which image had been used. The container-create event also did not include all data, for example, the security settings, volumes, mounts, and so on.
Beginning with Podman v4.4, you can gather all relevant information about a container directly from a single event and journald entry. The data is in JSON format, the same as from the podman container inspect command and includes all configuration and security settings of a container. You can configure Podman to attach the container-inspect data for auditing purposes.
Prerequisites
-
The
container-toolsmeta-package is installed.
Procedure
Modify the
~/.config/containers/containers.conffile and add theevents_container_create_inspect_data=trueoption to the[engine]section:$ cat ~/.config/containers/containers.conf [engine] events_container_create_inspect_data=trueFor the system-wide configuration, modify the
/etc/containers/containers.confor/usr/share/container/containers.conffile.Create the container:
$ podman create registry.access.redhat.com/ubi10/ubi:latest 19524fe3c145df32d4f0c9af83e7964e4fb79fc4c397c514192d9d7620a36cd3Display the Podman events:
Using the
podman eventscommand:$ now=$(date --iso-8601=seconds) $ podman events --since $now --stream=false --format "{{.ContainerInspectData}}" | jq ".Config.CreateCommand" [ "/usr/bin/podman", "create", "registry.access.redhat.com/ubi10" ]-
The
--format "{{.ContainerInspectData}}"option displays the inspect data. -
The
jq ".Config.CreateCommand"transforms the JSON data into a more readable format and displays the parameters for thepodman createcommand.
-
The
Using the
journalctlcommand:$ journalctl --user -r PODMAN_EVENT=create --all -o json | jq ".PODMAN_CONTAINER_INSPECT_DATA | fromjson" | jq ".Config.CreateCommand" [ "/usr/bin/podman", "create", "registry.access.redhat.com/ubi10" ]The output data for the
podman eventsandjournalctlcommands are the same.For more information, see the
podman-events(1)andcontainers.conf(5)man pages on your system.