Last active
October 22, 2019 06:50
-
-
Save csloz/0b1e1161bf6c6c77c3413437039c5c90 to your computer and use it in GitHub Desktop.
Docker update script to ensure docker containers are updated, dangling unused containers are nuked, and unused images purged.
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 | |
# Ensure docker is updated, and dangling / unused images are purged | |
# Restarts containers when done. | |
# Author: L. Sheed | |
# Delete all dangling (unused) images | |
docker images -q -f dangling=true | xargs --no-run-if-empty docker rmi | |
#prune anything unused and remaining | |
docker image prune -fa | |
# Update all docker containers | |
docker images |grep -v REPOSITORY|awk '{print $1}'|xargs -L1 docker pull | |
#restart any killed containers | |
docker-compose up -d --remove-orphans | |
docker restart $(docker ps -a -q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment