Tailing a docker image, to grep its output

Docker logs are very handy, it just takes the stout and stderr for you to see, the pickle is when you use docker logs it will not let you parse the output with grep.. I don't care about 90% of the output, just if it contains this small thing!

I found eventually a pretty good way to handle this:

tail -f "$(docker inspect --format='{{.LogPath}}' "$(docker ps --format="{{.ID}}" --filter="Ancestor=<Image>" -n 1)")"
Command to tail

This command will run docker ps with a filter on image, to identify what to retrieve the logpath of, then it will use docker inspect to identify where it stores its json log file.

You can now pipe that tail into a grep to parse the output as you need :)