Created
March 30, 2024 05:45
-
-
Save kn100/9f5d4ffede9e43a16852df3d532c4906 to your computer and use it in GitHub Desktop.
Hacky bash script to check what version if any of xz is inside your Focker containers.
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 | |
# Get list of all running Docker containers | |
containers=$(docker ps --format "{{.Names}}") | |
# Loop through each container | |
for container in $containers; do | |
# Get container image | |
image=$(docker inspect --format='{{.Config.Image}}' "$container") | |
# Execute xz --version inside the container | |
version=$(docker exec "$container" xz --version) | |
# Write container name, image, and command output to a text file | |
echo "Container: $container" >> docker_container_versions.txt | |
echo "Image: $image" >> docker_container_versions.txt | |
echo "xz Version:" >> docker_container_versions.txt | |
echo "$version" >> docker_container_versions.txt | |
echo "" >> docker_container_versions.txt | |
done | |
echo "Output written to docker_container_versions.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment