Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jcataluna/1dc2f31694a1c301ab34dac9ccb385ea to your computer and use it in GitHub Desktop.
Save jcataluna/1dc2f31694a1c301ab34dac9ccb385ea to your computer and use it in GitHub Desktop.
Script to save all images from a docker-compose.yml file
#!/bin/bash
mkdir -p out
for img in `grep image $1| sed -e 's/^.*image\: //g'`;
do
cleanname=${img/\//-}
tag=`docker images | grep $img | awk '{print $2}'`
echo "Exporting image: $img, tag:$tag ($cleanname)..."
docker save $img -o out/$cleanname.tar
ls -lah out/$cleanname.tar
tar -czvf out/$cleanname.tgz out/$cleanname.tar
rm -rf out/$cleanname.tar
done
@ooxoxx
Copy link

ooxoxx commented Feb 14, 2025

aggregating all the kindness discussion above:
docker save -o services.img $(docker compose config --images)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment