Created
September 5, 2024 07:35
-
-
Save exhuma/96f75568b39a49729cda26c3c4115457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ----------------------------------------------------------------------------- | |
# This script extracts the path of the devcontainer config-file from | |
# docker-events. | |
# | |
# This helps in identifying who has started a container if the container-name | |
# does not itself include any indication. | |
# | |
# This can be used to determine if a container can be safely stopped/removed | |
# | |
# It takes one argument: The container-name | |
# ----------------------------------------------------------------------------- | |
docker events \ | |
--filter="container=${1}" \ | |
--since="$(date --date '3 weeks ago' -Iseconds)" \ | |
--until="$(date -Iseconds)" \ | |
--format=json \ | |
| jq -c '{status: (.status | split(" ")[0]), config: .Actor.Attributes."devcontainer.config_file"}' \ | |
| sort \ | |
| uniq -c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment