I am using a fluentd container that mounts /var/lib/docker/containers directory and tails all of the logs for each container. The logs are stored in /var/lib/docker/containers/$container_id/$container_id-json.log. These do not contain the container name or the image name. I need to be able to add the container and image name in separate fields into every log coming from the log file.
The container name and image name are both stored in /var/lib/docker/container/$container_id/config.v2.json. I can't figure out how to get the image and name from that file and add it as a record to it's corresponding logs.
This was only my first thought and there may be a better way to do this, feel free to offer any advice.
Sidenote: I am intentionally not using fluentd as a docker logging driver because we previously used logspout in a similar manner. The current goal is to replace logspout with fluentd in a similar way. If the logging driver does provide this information in a much easier way then I would consider switching over later on.