Reputation: 673
I work on an application which needs to run a lot of short-lived containers using a command like docker run --rm MYIMAGE
I need to use --rm
to cleanup container resources after it exits to avoid running out of system resources over time.
Now I'd like to find out how long those containers are running on average. Is there some system level logs about what containers were executed and for how long they were running? Or does this information disappear after container is removed?
Upvotes: 1
Views: 929
Reputation: 1471
The Docker daemon does record container creation and deletion via events
. Those logs have timestamps and canonical references to container names, so could be used for your purposes.
Unfortunately there isn't (AFAIK) a good way to persist Docker events within docker itself (they can't be logged to a file), however you could use something like
curl --no-buffer -XGET --unix-socket /var/run/docker.sock http://localhost/events
and redirect that somewhere to get a log of Docker events created on a host.
Upvotes: 1