Skip to content

Instantly share code, notes, and snippets.

@Gronis
Created October 5, 2021 20:42
Show Gist options
  • Save Gronis/5b5d75dce2ebd30c1f40a8276798c4d0 to your computer and use it in GitHub Desktop.
Save Gronis/5b5d75dce2ebd30c1f40a8276798c4d0 to your computer and use it in GitHub Desktop.
Docker shell scripts
#!/bin/bash
date "+%Y-%m-%d %H:%M:%S"
sudo sh -c 'truncate -s 0 $(docker system info 2> /dev/null | grep "Docker Root Dir" | cut -d ":" -f2 | cut -d " " -f2-)/containers/*/*-json.log';
#!/bin/bash
# Remove images older than 1 week that has repository or tag <none>
docker rmi $(docker images | grep "<none>" | grep " [weeks|months]* ago" | awk '{print $3}') 2> /dev/null || true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment