Skip to content

Instantly share code, notes, and snippets.

@kn100
Created March 30, 2024 05:45
Show Gist options
  • Save kn100/9f5d4ffede9e43a16852df3d532c4906 to your computer and use it in GitHub Desktop.
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.
#!/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