Skip to content

Instantly share code, notes, and snippets.

@MatteoOreficeIT
Last active December 7, 2023 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatteoOreficeIT/56f9af563f87d615227e3bb17f207c0d to your computer and use it in GitHub Desktop.
Save MatteoOreficeIT/56f9af563f87d615227e3bb17f207c0d to your computer and use it in GitHub Desktop.
trovare un container a partire da overlay2
#!/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