Last active
December 7, 2023 11:50
-
-
Save MatteoOreficeIT/56f9af563f87d615227e3bb17f207c0d to your computer and use it in GitHub Desktop.
trovare un container a partire da overlay2
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 | |
# Specifica l'ID del layer di overlay2 | |
OVERLAY_ID="$1" | |
# Cerca il container associato all'ID del layer | |
CONTAINER_ID=$(sudo grep -l -r "$OVERLAY_ID" /var/lib/docker/overlay2/*/link | \ | |
sed -n 's|.*/overlay2/\(.*\)/link|\1|p') | |
# Ottieni il nome del container | |
CONTAINER_NAME=$(docker ps -aqf "id=$CONTAINER_ID" --format "{{.Names}}") | |
# Stampa il risultato | |
echo "Layer ID: $OVERLAY_ID" | |
echo "Container ID: $CONTAINER_ID" | |
echo "Container Name: $CONTAINER_NAME" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment